Maven Dependencies have no order , but the provide the concept of scopes.
So what you need to do is, use the scopes to build the right set of dependencies for:
- compile time
- runtime in the server: (use for example
provided
for dependencies that are needed at compiletime, but will be provided by the server, so your Application does/must not contain them
- test time: use the
test
scope to add dependencies that are only needed for testing (junit for example)
In your special case it looks like that javax.validation interface libary is not aviable in the tests. May they are not incuded in javaee-api
. If this is the case, then 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 behaviour sounds strange to me. - I recommend to double check what the server provides and what javaee-api
relay includes. But may I am wrong, and javax.validation
is only needed for test explicit
The reason why the problem only occoures when javaee-api
is included, could be, that javax validation sometimes is only turned on, when a implementation is aviable in the classpath.
The order of dependency matter in some cases. The "problem" is that if a libary/dependency is referenced in two places (direct and inderect) and the version of both references to the same library differers, Maven has to decide which version to use.
The first and most important criterium is the depth of the reference in the dependency tree. If you reference the library directly in your project POM, then this will be dominate all other. If the library is refered directly by a libary that is refered direcly by you, then this will dominate all other where is one more indirection.
But in case where are two references (to the same library in different versions) in the same depth of the dependency tree, the first one will win. (more details).
First of all,