I'm starting a new project with Spring Batch 2.1.6.RELEASE and I use Maven for depemdency management.
By default, it imports spring framework 2.5.6, but I'd like to use 3.0.5.RELEASE instead.
This post says it's compatible, but I don't know how to declare that in my maven pom file.
I tried just putting the dependencies for spring-core, spring-beans and spring-context versions 3.0.5.RELEASE, but that adds the libraries to the project without removing the 2.5.6 version.
I had a look at spring-batch-parent pom file, and there is a profile called "spring3" that uses the spring version I want. How do I activate a profile in my project's pom file ?
Thanks in advance,
Philippe
You can exclude the transient dependency on Spring Framework v2.5.6 of Spring Batch by using the dependency exclusions element of the spring-batch dependency in maven. Something like...
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>2.1.6.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<!-- Other exclusions here -->
</exclusions>
</dependency>
Related
I try to add Spring Data REST dependency using this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
After adding this dependency I catch an exception - java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;
And the Action suggestion: Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
I tried to add this dependency to fix the problem:
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
But it didn't help me.
How could I fix this problem?
I use Spring Boot version - 2.2.7.RELEASE, Maven version - 3.3.9
The requirement is to use spring boot version 2.2.6.RELEASE however the tomcat version should be 9.0.37.
I tried to do it by excluding the tomcat starter from the spring-boot-starter-web depdendency like so :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
And added the spring-boot-starter-tomcat separately which has the 9.0.37 tomcat version :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
However even after doing so the version is not override and the following gets used :
Mar 11 2020 09:31:38 UTC
Apache Tomcat/9.0.33
9.0.33.0
Do we need to do anything else to override the tomcat version?
Is it possible to override it by excluding started?
Update:
The parent pom is a corporate parent pom and not the spring-boot-starter-parent. As per one of the answers we can simply override the tomcat.version property however my effective pom doesn't show it.
If you're not inheriting from spring-boot-starter-parent I can only guess that you import spring-boot-dependencies in your dependencies management somewhere.
The documentation covers what you need to do to override the tomcat version. Each tomcat artifact should be listed with the overridden version, before you imports spring-boot-dependencies. The list of artifacts can be found in spring-boot-dependencies.
Using a different version of the starter is wrong (you can't mix two Spring Boot versions in the same app) and will have no effect since dependency management is in control anyway. In other words, you'll get spring-boot-starter-web version 2.3.2.RELEASE indeed but all the artefacts that it brings will be managed by the dependency management (the tomcat version defined by version 2.2.6.RELEASE).
In that particular case of yours, upgrading to 2.2.9.RELEASE could also be an option as it provides dependency management for the tomcat version that you need.
Well, this has been already answered.
For you, as you are using maven, you need to override the properties set in parent Spring pom.
<properties>
......
<tomcat.version>your_version</tomcat.version>
......
<properties>
For gradle, it is simple as
ext['tomcat.version'] = '8.5.34'
in your main build.gradle
Source: How to change embedded tomcat's version in existing spring boot app?
I'm a complete newcomer to Spring and I'm trying to set up a simple Spring application which I'm following through an online tutorial. The tutor is using Eclipse however and IntelliJ is complaining
Cannot find the declaration of element 'beans'.
....from within applicationContext.xml
My only Spring POM dependency:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
My applicationContext.xml
Do I have to setup this up from the 'Facets' context menu in Project Structure?? If so, how?
I have all the standard Spring plugins that come bundled in a typical Ultimate installation:
My project structure:
You have to use the following dependency also for Spring Beans apart from Spring Core.
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
I'm converting a project to maven and have found dependencies for every jar in the spring framework but the spring-build-src dependency.
Is this a necessary dependency and where could I find the dependency.
It's inside Spring Webflow (below the latest version, pick up the one you need)
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.4.2.RELEASE</version>
</dependency
I am starting out with Spring and I am reading Pro Spring 2.5. On page 17 they talk about Spring dependencies and I wonder if I need to add this myself in the POM, or does the dependency I have added below do this? Such as CGLib, dom4j etc?
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
You shouldn't need to. Maven will read the pom for spring-context and get any necessary dependencies that it has too, so you won't need to specifically put them in your own pom.
Check out this link it's really handy.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
This will just instruct maven that the current POM in which this is declared is dependent on this artfact, so when you compile the app it would make it available for you in classpath