Example code:
https://github.com/yszzu1/mvn-version-test
Question:
1. why the admin-module always using ojdbc8 19.3.0.0 ?
# mvn dependency:tree
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) # admin-module ---
[INFO] org.example:admin-module:jar:3.12.0
[INFO] +- org.example:db-module:jar:3.12.0:compile
[INFO] | \- com.oracle.database.jdbc:ojdbc8:jar:19.3.0.0:compile
as we can see that the db-module is using 19.9.0.0
2. even after upgrade the db-module pom.xml with
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.1.0.0</version>
</dependency>
, the admin-module mvn dependency:tree is still showing 19.3.0.0
mvn & windows & JVM version:
# mvn --version
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: C:\Users\shuayan\Documents\open\apache-maven-3.8.5
Java version: 1.8.0_321, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_321\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
BTW: I have read these two wiki
https://www.mojohaus.org/versions-maven-plugin/faq.html
https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401
That is how dependency management works in maven.
you have defined direct ojdbc8 dependency for db-module and it does work as expected
for admin-module the situation is "bit different":
it depends directly on db-module, and ojdbc8 is now a transitive dependency
it inherits ojdbc8 version from spring-boot-starter-parent (actually from spring-boot-dependencies)
if you really want to use spring-boot-starter-parent as a parent you need to configure your project in the following way:
/pom.xml:
<properties>
...
<ojdbc.version>21.1.0.0</ojdbc.version>
<oracle-database.version>21.1.0.0</oracle-database.version>
...
</properties>
/db-module/pom.xml:
<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<!-- omit version information -->
</dependency>
</dependencies>
Related
I am trying to add secrets to spring boot app.
so added to pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
<version>3.4.0</version>
</dependency>
Maven version is
xyz_pqr#cloudshell:~/projects/spring-petclinic (xyzprj)$ ./mvnw --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f) Maven home:
/home/xyz_pqr/.m2/wrapper/dists/apache-maven-3.8.2-bin/1um3pu5poco57pibs3g92d6vrf/apache-maven-3.8.2
Java version: 17.0.4, vendor: Debian, runtime:
/usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform
encoding: ANSI_X3.4-1968 OS name: "linux", version: "5.15.65+", arch:
"amd64", family: "unix" xyz_pqr#cloudshell:~/projects/spring-petclinic
(xyzprj)$
It gives the issue
Failed to execute goal on project spring-petclinic: Could not resolve dependencies for project org.springframework.samples:spring-petclinic:jar:3.0.0-SNAPSHOT: Could not find artifact org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0 in spring-snapshots (https://repo.spring.io/snapshot)
The complete error is
[INFO] ------------< org.springframework.samples:spring-petclinic
------------ [INFO] Building petclinic 3.0.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- Downloading from spring-snapshots:
https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
Downloading from spring-milestones:
https://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
Downloading from central:
https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.pom
[WARNING] The POM for
org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0
is missing, no dependency information available Downloading from
spring-snapshots:
https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
Downloading from spring-milestones:
https://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
Downloading from central:
https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starter-secretmanager/3.4.0/spring-cloud-gcp-starter-secretmanager-3.4.0.jar
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 3.274 s [INFO] Finished at: 2023-01-14T23:34:50Z
[INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal on project spring-petclinic: Could not
resolve dependencies for project
org.springframework.samples:spring-petclinic:jar:3.0.0-SNAPSHOT: Could
not find artifact
org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar:3.4.0
in spring-snapshots (https://repo.spring.io/snapshot) -> [Help 1]
[ERROR] [ERROR] To see the full stack trace of the errors, re-run
Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to
enable full debug logging. [ERROR] [ERROR] For more information about
the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
xyz_pqr#cloudshell:~/projects/spring-petclinic (xyzprj)$
The issue is with document at Secret Management
it says
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
but should be
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
so replace org.springframework.cloud with com.google.cloud
My project is using another library commons-collection, which I have no control of. I run the command:
mvn dependency:tree -Dverbose -Dincludes=commons-collections
Verbose not supported since maven-dependency-plugin 3.0
[INFO] com.jde.jnlu:jnlu-qe-web:war:1.0.0-SNAPSHOT
[INFO] \- com.jde.jimi3.data:jd-jimi3-data-sdk:jar:3.0-SNAPSHOT:compile
[INFO] \- com.jde.jmq:jmq-client-spring:jar:2.1.2:compile
[INFO] \- com.jde.jmq:jmq-client-core:jar:2.1.2:compile
[INFO] \- com.jde.jmq:jmq-client-json:jar:1.2.9:compile
[INFO] \- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] \- commons-collections:commons-
collections:jar:3.2.1:compile
As it can been seen, the "commons-collections" is introduced by jd-jimi3-data-sdk which I can't update. But I was reminded of the current version of "commons-collection" has a potential security issue and needs to be upgraded. How can I achieve that in my project?
In your project, if you declare an explicit dependency on the version of commons-collection that you want, Maven will use that instead. See Maven documentation: Resolving conflicts using the dependency tree.
If you want to be really sure, you can also (in addition to the above) exclude commons-collection from your jd-jimi3-data-sdk dependency. Something like:
<project>
...
<dependencies>
<dependency>
<groupId>com.jde.jimi3.data</groupId>
<artifactId>jd-jimi3-data-sdk</artifactId>
<version>3.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
This is also covered in the Maven documentation: Dependency Exclusions.
Warning: Since the library you are using - jd-jimi3-data-sdk - was not written with this version of commons-collections, and allegedly not tested with it, this may break you project!
I am using Eclipse Juno integrated with maven plugin.
I have installed JDK 1.6 on my system.
My environment variables are
JAVA_HOME - F:\Program Files\Java\jdk1.6.0_37
MAVEN_HOME - F:\apache-maven-3.0.4
classpath - ;.;%JAVA_HOME%\lib\tools.jar;
Path - C:\Program Files\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;.;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;
My JDK and JRE are working smooth.
Command Line Check :
In my eclipse I am building a new maven web project which should give me a war file.
My pom.xml :
<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.achutha.labs</groupId>
<artifactId>01JsfExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>01JsfExample</name>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<finalName>JavaServerFaces</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
If I do maven clean, its a success.
But when i do maven install it is giving some jdk issues.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building 01JsfExample 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # 01JsfExample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) # 01JsfExample ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\Workspace\01JsfExample\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
F:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.554s
[INFO] Finished at: Mon Dec 10 06:54:01 IST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project 01JsfExample: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] F:\Program Files\Java\jre6\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
My other java programs on eclipse are compiling and running fine.
Except for maven projects. The war file is not getting generated as build is failure due to the above reason.
How to solve this issue ?
Are you running Maven goals in Eclipse? If so, it looks like Eclipse is trying to access the JRE as opposed to the JDK: F:\Program Files\Java\jre6\..\lib\tools.jar
Although JAVA_HOME seems to be set correctly at the Windows level, it could be that in Eclipse you're running the app with a JRE, not a JDK. In Eclipse, have a look at the installed JREs list (Window -> Preferences -> Java -> Installed JREs). If you don't have a JDK, click on 'Edit' after selecting the JRE and in that dialog box enter the location to the JDK.
I am assuming that you are trying to use maven install option from eclipse. Try mvn install from command line. If that fails the issue is with java setup ( installation, path, variable ). Recheck whether your java home is correctly pointing to jdk and not jre. Also ensure eclipse javaw.exe from jdk bin directory.
If cmd line install works then issue is with eclipse java configuration for your maven project. You can try resolving it by -
You should verify the project properties set up in eclipse to ensure the java runtime is the correct one.
You should verify in the project facet the java compilation is set to 1.6
You should set java compilation information in pom.xml sourcejdk and targetjdk tags.
I have a multi-module project that looks like this:
module1
pom.xml
module2
pom.xml
pom.xml
The pom.xml in module2 has a dependency on module1.
When I run mvn clean compile I get the following error:
The projects in the reactor contain a cyclic reference.
Here are my dependencies in module1:
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.48</version>
</dependency>
</dependencies>
I can't figure out why it says there is a cyclic reference. Even when I do mvn dependency:tree on module1 I get the following:
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.48:compile
[INFO] \- junit:junit:jar:4.8.2:test
It looks to me like there aren't any references to module2 in module1. So where is the cyclic reference coming from?
Edit: Here is the log with debug on:
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_31
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:295)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: hidden.org.codehaus.plexus.util.dag.CycleDetectedException: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --> com.myorg:module2 --> com.myorg:module1
at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:143)
at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:123)
at org.apache.maven.project.ProjectSorter.<init>(ProjectSorter.java:118)
at org.apache.maven.execution.ReactorManager.<init>(ReactorManager.java:99)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:288)
... 11 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Jul 05 17:21:21 EDT 2012
[INFO] Final Memory: 3M/244M
[INFO] ------------------------------------------------------------------------
Ah! It was a misleading error.
The problem wasn't that there both module1 and module2 depended on each other. The problem was that module2 is a Maven plugin and in my root pom.xml I had the plugin in the section. I removed that plugin from the build and it started working.
It happened to me in this circumstances.
The module_child_X was specified 2 times at module_root pom.xml:
- As a module
(pom.xml of the root module)
<dependency>
<groupId>module_root</groupId>
<artifactId>module_child_X</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
- As a dependency
(pom.xml of the root module)
<modules>
<module>module_child_X</module>
...
</modules>
Solution?
Removed the module_child_X as a dependency. It is already specified as a module.
I do nearly the same, and I use IDEA.
I have a project A, which depends on a module B.
In the pom file of A, B was declared as a dependency. This is OK.
In the pom file of B, A was declared as its parent. I removed this information, and as it was requested in the error message I added the version number of B in its pom file.
And now it is OK.
I had exactly the same issue in a multimodule ear project. The ejb pom had a dependency on the web module (compile scope) and the web pom a dependency on the ejb module. As soon as i removed the ejb's pom dependency on the web module, the project build fine.
It makes sense that the intramodule dependencies must be unidirectional after all, in order to avoid cyclic references.
I am working my way through the Spring Roo Tutorial and I get stuck at this point:
http://static.springsource.org/spring-roo/reference/html/beginning.html#beginning-step-7
This is the Maven Command line output:
C:\pizza>mvn selenium:selenese
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pizzashop 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- selenium-maven-plugin:2.1:selenese (default-cli) # pizzashop ---
log4j:WARN No appenders could be found for logger (org.openqa.selenium.server.SeleniumServer).
log4j:WARN Please initialize the log4j system properly.
14:53:20.476 INFO - Preparing Firefox profile...
14:53:23.026 INFO - Launching Firefox...
at this point my FireFox 11 browser is launched but there is now visible URL and everything just seems to hang.
Any suggestions or ideas are welcome.
Environment:
OS Windows 7
JDK 1.6
Maven 3.0.3
Firefox 11
latest spring roo downloaded
It's the selenium plugin configuration in the pom.xml. Note: Out of the box ( so to speak ) Roo is going to expect firefox 3.x You can either install Firefox 3.x or you can change the configuration to use another supported browser - for example:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<browser>*safari</browser>
<suite>src/main/webapp/selenium/test-suite.xhtml</suite>
<results>${project.build.directory}/selenium.html</results>
<startURL>http://localhost:4444/</startURL>
</configuration>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
</plugin>