I'm not an expert about versions of spring boot starters and have faced with problem. I'm trying build my project with this spring boot starter. And I need the embedded libraries version to be 5.2.0 as it says in description of this jar file. But when I added this dependency into my project I found that embedded libraries versions are different that I expected. My maven plugins shows that versions 5.1.6 and my code doesn't compile because some classes depend on methods from 5.2.0 module.
And there is one more thing. In another project I added the same dependency. But it's ok, versions are the same with description from maven repositoty.
There is difference between these two project. One of them with spring-boot version 2.1.9 (which not compiles) and another - 2.3.4 (whihk works good). And when I checked versions of containing into starter libraries via artefactId in pom - they are ok and 5.2.0.
Here pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>adapters</artifactId>
<groupId>com.alarislabs</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>security</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
</dependencies>
I've tried to delete m2 repo with all maven dependencies and then download again but I still have problem. I've made a mistake in pom.xml? Maybe is something wrong with my IntelliJ?
Versions of dependency in pom
Wrong versions in plugin
Correct versions in plugin
Spring Boot manages several dependencies versions so that we can ensure they are compatible with each other.
Look at this pom.xml file to see which dependencies version are managed by Spring Boot 2.3.4.RELEASE. You can change the version number and see the managed dependencies in that version.
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.3.4.RELEASE/spring-boot-dependencies-2.3.4.RELEASE.pom
Benefits:
If you want to use a dependency out of the dependency list, you do not need to specify the version in in your pom.xml. Or check if an official spring-boot-starter for that dependency exists. If it exists, just use the spring-boot-starter dependency. Again no need to specify the version.
Spring will pull the dependency that works well with all other libraries so that you won't get compatibility (runtime or compile time) error
When you upgrade spring boot's version, all the managed dependencies will get updated. And also the compatibility is maintained.
How to solve your problem:
In your pom.xml, you don't need to specify the version for spring-boot-starter-oauth2-resource-server. This library is managed by spring boot. It looks you are specifying version 2.2.0 which is not compatible with your spring boot version 2.1.9.
Related
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 creating an application using Spring Boot and also Elastic-Search. Spring application part is working. And also when I start Elastic server, it's also running well. No issues at all. I can test it via POSTMAN and also CURL. Adding and also searching works well.
But when I run the application, i'm getting following issues.
This is the issue i'm getting in the IDE. (which means from my java application)
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
And this is the issue i'm getting from the Elasctic server on my local system.
java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
These are the libraries I'm using.
Spring Boot 1.5.1.RELEASE
Spring Boot Starter Data Elasticsearch 1.5.1.RELEASE
Spring Data Elasticsearch 2.10.RELEASE
Elastic Search 5.0
I think this is a issue with Elastic and above library version mismatch.
I'm new to Elastic and also Spring. The version issue is here.
https://github.com/spring-projects/spring-data-elasticsearch/wiki/Spring-Data-Elasticsearch---Spring-Boot---version-matrix
And also here is my pom.xml. If I need to update any library, can anyone tell me what's that ? And also tell me how to update those libraries ? Can I update them without changing to my source code ?
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<artifactId>springboot-springdata-elasticsearch-example</artifactId>
<packaging>jar</packaging>
<url>https://www.mkyong.com</url>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Runtime, for Embedded Elasticsearch,
comment this if connect to external elastic search server-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In this pom.xml , I can't find all the dependencies too.
According to the versions matrix that you provided, the spring boot version that you're using is not compatible with ElasticSearch 5.x instances. So, i think you have 3 options:
If you really need to work with SpringBoot 1.5.1 using ElasticSearch 5.0, you should add the maven dependencies related to ElasticSearch 5.0 and implement your own DAO service.
You can try to downgrade your ElasticSearch version to 2.4 in order to make it compatible with your current spring boot version.
Maybe you can try to use the recent spring boot version (1.5.4) because arcording to the spring-data-elasticsearch project (https://github.com/spring-projects/spring-data-elasticsearch/), the last version supports ElasticSearch 5.x, so probably it could be the easiest way.
Please let me know if any of options above was useful for you.
I am working with a Maven project where I have spring framework dependency version 3.2.3.RELEASE and I have to import this project into many others but in some of them I am using spring 4.
How can I exclude this dependency (spring 3) only in case that the project that uses mine has the same or newer version of spring and in those who hasn't use mine?
One thing you can do is to manually exclude unwanted dependencies:
<dependency>
<groupId>com.your.project</groupId>
<artifactId>project-name</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-core</groupId>
</exclusion>
</exclusions>
</dependency>
But that can get quite verbose.
It may help if you elaborate a bit more on the problem description as it is not clear to me what exactly are you trying to solve or achieve.
For instance if you include a dependency A which has a dependency B in version 1.0 and then you include B in your pom in 1.1 Maven will use only 1.1. I recommend reading up on it a bit here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies
Currently I have a Gradle build for a Java Web Start Swing application that works. It's mainly using the steps outlined in: http://www.apprenticeshipnotes.org/2013/01/generating-webstart-files-using-gradle.html
The huge issue with doing a Gradle build this way, is that we are wasting time signing unchanging JARs every time we do a build (by far where most time is spent) in order to build the application.
I've been looking at Gradle code on Github, looking at other recipes that might point me in the right direction, but I can't seem to determine how I would go from a set of tasks that takes the build artifacts of an existing configuration, signs them, and then bundles them into the application to something that is much more efficient.
My idea was to have the ability to resolve dependencies, then determine if there was a 'signed' version of that dependency in the repository. If there was not a signed dependency, the build would sign that artifact and upload to a repository.
An easier approach that I was trying to take was a project that takes the runtime configuration of the application project and somehow loops over the dependencies and signs them and uploads the artifacts to a repo, but it's not clear to me how I could do this with the Configuration API. Just getting at the files of the configuration is not enough, because I would want dependency information for each JAR file.
It also gets a bit trickier with uploading the JARs, because if, for example, I upload a signed jar, say metrics-json-3.0.2.jar, as metrics-json-signed-3.0.2.jar, I would need to update the POM to reference the signed artifacts. Seems like there should be an easier approach
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-parent</artifactId>
<version>3.0.2</version>
</parent>
<artifactId>metrics-json</artifactId>
<name>Jackson Integration for Metrics</name>
<packaging>bundle</packaging>
<description>
A set of Jackson modules which provide serializers for most Metrics classes.
</description>
<dependencies>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
Note, this is different from the signing mechanism provided by the existing Signing Plugin:
http://www.gradle.org/docs/current/userguide/signing_plugin.html
I have recently started having trouble releasing a maven project which has worked fine for a long time now. The project consists of several modules with a structure looking something like:
project_server
project_webserver
project_qp
project_qp_ingr
project_repo
project_repo_ingr
Both modules project_qp and project_repo are dependent on project_webserver with ${project.version} references.
The project is build using Jenkins and everything works fine when I am building snapshot builds.
When I try to build a release with version 3.1-RC1 in a maven release build configuration with the options/goals "-Dresume=false release:prepare release:perform -e", everything works fine in the "clean, verify" phase, but in the "deploy, site-deploy", project_repo suddenly doesn't compile.
The compilation errors consist of the module not finding classes from the project_webserver module. However, the project_qp_ingr module has already been built and is working fine.
All of this suggests to me that there is something wrong with the reference from project_repo_ingr to project_webserver but since the project builds fine when I am building snapshot releases.
The pom of project_repo_ingr looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>project_repo_ingr</artifactId>
<name>project_repo_ingr</name>
<packaging>jar</packaging>
<parent>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_repo</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_webserver</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_webserver</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have omitted some dependencies but that is pretty much it. Both the module project_repo_ingr and project_qp_ingr have the dependency to both the regular artifact and the test-jar.
I use Java 6, Maven 2 and Jenkins 1.436 with M2 Release Plugin 0.8.1.
Any help is greatly appreciated, I have torn my hair all day long about this.
Update:
The changes that I have made since the last time this worked is branching the svn repo from the trunk to a release branch. The jenkins job in trunk has been copied into one for the branch and the svn path is changed. I have also updated the part of the project_server pom.