Maven Dependencies are not ordered , but provide the concept of domains .
So what you need to do, use the scope to create the correct set of dependencies for:
- compilation time
- runtime on the server: (use, for example,
provided
for dependencies that are necessary in compiletime, but will be provided by the server, so your application should / should not contain them - testing time: use the
test
scope to add dependencies that are only needed for testing (e.g. junit)
In your special case, it looks like the interface is not available in javax.validation tests. Let them not go into javaee-api
. If so, add:
<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> <scope>test</scope> </dependency>
But be careful , your explanation about what is included in the server, and the described behavior sounds strange to me. - I recommend double checking what the server provides and that includes javaee-api
. But can I be wrong, and javax.validation
is only required to check for explicit
The reason that the problem only occurs when javaee-api
may be because javax checking is sometimes only enabled when the implementation is available in the classpath.
The order of dependence depends in some cases. The “problem” is that if the link to libary / dependency is referenced in two places (direct and inderect), and the version of both links to the same libraries is different, Maven must decide which version to use.
The first and most important criterion is the link depth in the dependency tree. If you reference the library directly in your POM project, then this will dominate everything else. If the library refers directly to the library that you directly pointed out, it will dominate everything else, where there is another indirect appeal.
But in case two links (to the same library in different versions) at the same depth of the dependency tree, the first will win. ( more details ).
Primarily,
Ralph source share