JUnit testcase passes with eclipse but fails with maven build

自闭症网瘾萝莉.ら 提交于 2019-12-01 22:32:42
Avinash Kulkarni

I have solved this problem. The problem was mainly because of the dependency

<dependency> 
    <groupId>javaee</groupId> 
    <artifactId>javaee-api</artifactId> 
    <version>5</version> 
    <scope>provided</scope> 
</dependency>

Actually this dependency was required for EJB so I placed this in my parent pom (and also in my testcases pom). Since my test case's pom had a parent depedency, by default it will be inherited. If you add this dependency then u must have a java EE container to run the program. Testcase does not require Java EE container.

Remove this dependency if you have the one in your pom file.

Have a look on Problem running unit tests from maven (JPA related) for more detail.

Ralph

It looks like you run in a Problem with the Java EE API package that contains only empty interfaces.

Replace

<dependency>
    <groupId>javaee</groupId>
    <artifactId>javaee-api</artifactId>
</dependency>

by:

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>

More details can be found here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!