Reputation: 8122
I have a project where I use Spring Boot 1.1.2.RELEASE which uses Spring 4.1.5, and Spring HATEOAS 0.10.0.RELEASE which uses Spring 4.0.9. This causes some dependency problems like the infamous java.lang.ClassNotFoundException: org.springframework.beans.factory.SmartInitializingSingleton
.
I dug into the POM of spring-hateoas
and found that there are different profiles defined, one of them being spring41
which depends on Spring 4.1.5. Is it possible to select this profile in my <dependency>
section, or do I have to exclude the Spring dependencies?
Upvotes: 2
Views: 513
Reputation: 328594
Automatically selecting a profile for a build isn't easy. You can enable it by default in your personal settings.xml
but that breaks the build for everyone who doesn't have the same file.
You can't enable a profile in the POM of the project.
With Maven 3.3, you can add the profile to ${maven.projectBasedir}/.mvn/maven.config
. Since this file is part of the project, it's easy to share. You can use the Maven Enforcer plugin to make sure everyone uses a Maven version with actually uses the file.
If you can't use 3.3, then your best bet is to exclude the dependencies. If you have a parent POM, then you can use a dependencyManagement
element to do it for all POMs in the reactor build.
Upvotes: 2