The POM is missing, no dependency information available - java

Parent pom has dependencyManagement for spring-boot-dependencies version 2.5.4. Still I get this warning for child pom mvn build:
The POM for org.springframework.boot:spring-boot-starter-quartz:jar:2.5.4 is missing, no dependency information available

Declarations in <dependencyManagement> do nothing but being a template for the configuration once a dependency is used in <dependencies> later on.

Related

How to inherit dependency version from required BOM POM in maven spring boot project?

I am new to spring boot world and encountered with an issue. I have a requirement of using mssql in my project which I am default getting as a dependency from spring-boot-starter-parent but the catch is the version which is getting inherited is what i do not want.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<type>pom</type>
</dependency>
This will give me mssql version mssql-jdbc : 6.1.0.jre7 (Which i do not want)
My organization has a dedicated BOM POM created for all the common components used in all the projects which includes mssql latest version. mssql-jdbc :8.4.1.jre8
I have declare this BOM POM under dependencyManagement tag.
<dependencyManagement>
<dependencies>
<dependency>
<grpId></grpId>
<artifactiID></>
<version/>
</dependency>
</dependencies>
</dependencyManagement>
Now my POM is only taking mssql version from spring boot parent (Which is obvious as per the tree hierarchy) but i want to use version from BOM POM.
I also don't want to hardcode the mssql version in my pom dependency like
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>It should take from the BOM POM declared in dependency management</version>
So that whenever a new version got updated in my BOM POM, it should reflect directly in my application POM file.
my question can be repetitive or easy to figure out but as i am new to the spring world, Your help will be helpful for sure.
Thanks is advance.
Not possible.
Parent POM versions are stronger than BOM versions.
You need to add the version explicitly in your POM and change it manually when the BOM changes.
To override the version of a dependency you have to find how it was defined in the parent POM. Example in your case, if you look at the Spring Boot parent POM, in the <properties> section, you should see something like:
<mssql.version>Y.XX</mssql.version> <!-- please note that I am not really sure about the property name but I am 100% that the version is defined as a property-->
Then copy-paste that property in the <properties> section of your POM and set the version you want.

How to update parent dependency after i update children denpendency using maven

I use IDEA,My springboot app contains multiple modules like that:
parent
-web
-service
-dao
There is a jar dependency common:1.2.0-SNAPSHOT in service module defined in pom.xml, I updated its version to 1.3.0-SNAPSHOT, after that i do maven reimport and run mvn clean install -U but these two versions still in dependencies list, and in dependency tree, two jar in the dependencies, also when i run the app, it throw NoClassDefFoundError error which i added in 1.3.0-SNAPSHOT
This is my maven dependenct tree:
service:jar
+- dao:jar
\- common:jar:1.3.0-SNAPSHOT
web:jar
+- service:jar
+- dao:jar
\- common:jar:1.2.0-SNAPSHOT
\- others:jar
service pom dependency:
<dependency>
<groupId>com</groupId>
<artifactId>common</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
How can i update the dependency?
As #Haroon #chrylis said, i checked the parent pom.xml and found <parent> configured in this pom.
<parent>
<groupId>insight.plat</groupId>
<artifactId>insight-bom-base</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
in pom insight-bom-base, common 1.3.0-SNAPSHOT is configured, so web module depend this version not version 1.2.0-SNAPSHOT.
<dependencyManagement>
<dependency>
<groupId>com</groupId>
<artifactId>common</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependencyManagement>
As maven doc Transitive Dependencies shows,
Dependency management - this allows project authors to directly specify the
versions of artifacts to be used when they are encountered in transitive
dependencies or in dependencies where no version has been specified.
In the example in the preceding section a dependency was directly added to A even though
it is not directly used by A.
Instead, A can include D as a dependency in its dependencyManagement section and directly
control which version of D is used when, or if, it is ever referenced.
The parent dependencyManagement has higher priority than Transitive Dependencies, so in service module, it use common 1.2.0-SNAPSHOT

Specific spring-core jar to be included in project

Ive included following lines in my pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
The specific spring-core JAR version I want is 4.1.6, but whenever I do an mvn clean install, the dependencies folder under my project in netbeans shows a downgraded version (currently 3.0.7.RELEASE).
I want to know how I can force maven to put 4.1.6.RELEASE jar in my dependencies folder. I've done
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
And I've the folder 4.1.6.RELEASE with correct jar in my local /.m2/repositories folder. I need to access org.springframework.util.MimeType class which is not available in spring-core 3.0.7.RELEASE jar.
See the result of mvn dependency:tree to know if another jar bring back the version 3.0.7. and exclude from this dependency the spring-core
See the same result to know if the right version is present
Add the pom.xml and the result of mvn dependency:tree in the question
Please follow these steps:
Check in .m2 local repository where the Spring 3.0.7 jar is downloaded(It should be under folder org->springframework)
Delete the folder present inside springframework, so that mvn will try to fetch required dependencies.
Let me know if it helps
The issue is that spring-core is a mandatory dependenecy of most spring artifacts. Most likely you are using a dependent artifact e.g spring-context which is of version 3.0.7. Then Maven is fetching spring-core of the same version as the dependent artifact using its transitive dependency mechanism.
To control the version of spring-core you need to move its declaration from the dependencies section to the dependency management section of your pom.xml as follows
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Using maven versions plugin to handle dependency version

I have the a project pom and a parent pom. The parent pom defines a dependency as follows:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycode/groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
My project pom inherits the parent and defines the dependency.
<parent>
<groupId>au.com.truelocal</groupId>
<artifactId>truelocal-parent</artifactId>
<version>develop</version>
</parent>
<dependencies>
<dependency>
<groupId>com.mycode</groupId>
<artifactId>common</artifactId>
</dependency>
</dependencies>
I used to build with Maven this way without issue.
I now want to start having a different version in parent, common and project.
I am going to use the maven versions plugin to set my version.
I am setting the parent version and version successfully however, maven keeps looking for the wrong version of common. E.g. if my project is building as version 1.0.0-4 then it looks for common-1.0.0-4 but I actually need it to get the latest version of common instead which could be for example 1.0.0-23.
Can i use the versions plugin to adjust my dependency version? How do I make it only apply to common and not other dependencies I may have?
mvn versions:set (I guess this is what you've done) sets the version of your project, respectively the project versions which are part of a multi module project.
It doesn't touch the versions of the dependencies, either they are configured in a parent pom within <dependencyManagement> or within <dependencies>.
You can adjust the dependency versions by several ways: mvn versions:display-dependency-updates , mvn versions:use-latest-releases , mvn versions:use-latest-snapshots.
Use mvn versions:help or mvn versions:help -Ddetail=true -Dgoal=use-latest-snapshots to get more informations.

Resolve maven dependencies from child pom

I'm quite new to maven and I have a maven multi module project with the parent pom as
<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>
<groupId>com.test.cit</groupId>
<artifactId>cit</artifactId>
<version>LATEST-SNAPSHOT</version>
<name>Integration Test Framework</name>
<packaging>pom</packaging>
<modules>
<module>common</module>
<module>core</module>
<module>login</module>
</modules>
</project>
I have put all the relevant external dependencies to the child poms of common, core and login. I then converted the project to an eclipse project (mvn eclipse:eclipse) and after that eclipse is unable to resolve the dependencies in the child pom though the respective jars are present in M2_HOME.
I then added all the dependencies to the parent pom(Whatever dependency was there in the child poms) from the child poms and then eclipse was able to resolve that.
I'm confused of this behavior. Since I've already added the external dependencies to the child poms why should I add again that to the parent pom?
Anybody could you please explain this or am I doing something wrong here to fix the problem.
In the parent pom you have the option to add two tags :
<dependencies></dependencies>
and
<dependencyManagement></dependencyManagement>
In the <dependencies> tag you have to place all the dependencies that you want that all you projects includes, for example JUnit dependency or Log4j.
In the <dependencyManagement> tag you should add all the dependencies that your project needs, It does not means that they are going to be included in all your projects. It only means that your child projects can include them or not. It is going to help you to manage the versions.
Maybe you have problems in the dependency bewteen your child projects for this reason when you add all the dependencies to your parent project It works.

Categories

Resources