I found something doesn't work that I expected to work.
I imported the org.glassfish.jersey:jersey-bom in my dependencyManagement section.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.26-b03</version>
<type>pom</type>
<scope>include</scope>
</dependency>
</dependencies>
</dependencyManagement>
That pom clearly includes following dependency.
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${project.version}</version>
</dependency>
Now I add my own dependency
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And mvn complains.
'dependencies.dependency.version' for org.glassfish.jersey.core:jersey-common:jar is missing. # line 33, column 17
What's wrong with my pom?
Did you define project-version as a property? I guess not, since you're not using it to specify the version of your BOM.
Using the literal string, this should work:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.26-b03</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26-b03</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
</dependency>
</dependencies>
What intrigues me is that you shouldn't need to specify org.glassfish.jersey.core:jersey-common:2.26-b03 in <dependencyManagement> since it is part of the BOM, but the dependency doesn't work if it is not there.
Related
I have a single-module maven project which uses a number of Kotlin libraries, and I'm trying to specify the kotlin-bom to ensure they all use the same version. I've got the following in my pom.xml:
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.6.20</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
...
However, when I do mvn compile, I get this error:
[ERROR] 'dependencies.dependency.version' for org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar is missing.
How can I use kotlin-bom in a single-module project?
Move your bom declaration to dependencyManagment section
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.6.20</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
</dependencies>
Can a Maven BOM(BOM1) contain another BOM(BOM2) in its dependencyManagement? If yes, how could the usage of BOM1 through inclusion in a pom.xml can use the dependencies from BOM2 in a project? Thanks in advance!
To better explain the situation, the below works when i include both of the in the pom.xml of the service:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>my.custom.bom</groupId>
<artifactId>my.custom.bom</artifactId>
<version>${my.custom.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Whereas the following does notwhen I include it in the pom.xml of the service:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.custom.bom</groupId>
<artifactId>my.custom.bom</artifactId>
<version>${my.custom.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
And the my.custom.bom in the second situation includes the spring-boot-dependencies like so:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
To summarize when pom.xml includes BOM1 and BOM2 works, but when pom.xml includes BOM1 and BOM1 includes BOM2 no longer works.
i have a pom that has a number of entries in its <dependencyManagement> section.
How can i figure out which dependencyManagement entry is managing the versions of my dependancies!?
To further clarify my question, sometimes it is obvious -
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>${spring-cloud-gcp.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
, would manage this verion:
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
</dependency>
</dependencies>
But what about dependencies that are declared (without a version) that dont match the groupId, etc.
Thanks
Why override org.webjars when using org.springframework.cloud dependency ? there is any dependency vise versa? I am confused .
See below snippet:
In pom.xml file:
override dependencies:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>datatables</artifactId>
<version>1.10.19</version>
</dependency>
when i am using below dependency:
<project>
......
<!-- Some dependencies -->
.....
<dependencies>
......
.......
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
<!-- Some dependencies -->
.......
</project>
This post explained exact problem: Overriding managed version 3.2.0 for bootstrap when put <dependencyManagement>
Please help me.
Here is my problem, I have a parent pom.xml which defines the:
--------parent pom.xml-----------------
<dependencyManagement>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0.3</version>
</dependency>
</dependencyManagement>
Inside this roboletric pom.xml we have:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-ant-tasks</artifactId>
<version>2.1.3</version>
</dependency>
Inside the maven-ant-tasks pom.xml, it has:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.2.1</version>
</dependency>
So whenever I am calling the API which only exists in the maven-artifact 3.0.3 in the roboletric test case, it will throw nosuchmethod exception.
So I have tried:
1. <dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
I also tried moving:
org.apache.maven
maven-artifact
3.0.3
to the child pom under the <dependencyManagement> which I think it should override the parent but actually it didn't.
I think this kind of problem should be very common but I just can't figure it out, any suggestions?
You should define dependency management in your parent POM to nail down the version of maven-artifact in all (transitive) dependencies:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
</dependencyManagement>