简体   繁体   中英

Maven Test Dependencies with Eclipse

We are using Spring, Maven and Java in our project. Sometimes we include dependencies to modules with scope "test". So these are only availabe in test, not in production. Unfortunately eclipse is not that intelligent. So when you use classes from those Test-Dependencies, you don't get compile errors. But when you later build it in some continuus integration environment via Maven (not compiling in eclipse) the correct workspace resolution gets used and it ends up with a compiler error. Class Not Found...

Does anyone have a solution for this?

Maven using: you define in pom.xml. you put on with hand.

how to do:

<!-- prod jar hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency> 
<!-- testjar hibernate -->
        <dependency>
            <groupId>org.hibernate.test</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency> 

you open to project path. you open window cmd with win+r short-key.

mvn clean install -DskipTests 

(maven-3.5 add environment variables) if you see build success, nop.

we adding .jar with dependency. don't forget. (test or really .jar)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM