I declare in the parent POM
<dependencyManagement>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
<scope>compile</scope>
</dependency>
</dependencyManagement>
Further, the child pom use
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
All work fine? but when I use such dependency with type = pom
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>${jboss-javaee-7.0.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
I have error
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project by.services:by.utils:1.0.2 (D:\Work\V2_Change_Maven_Structure\by.utils\pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for org.jboss.spec:jboss-javaee-7.0:jar is missing. # line 18, column 21
[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.
How to declare a dependency in dependencyManagement with type = pom
$ {Jboss-javaee-7.0.version} announced
If I bear jboss-javaee-7.0 in the root, then runs
The clarification here is that when you do not define <type> on your </dependency> within </dependencyManagement> it defults to jar
<dependencyManagement>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
<scope>compile</scope>
<type>jar<type> <!--default value-->
</dependency>
</dependencyManagement>
and hence the module uses that jar while using it as
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
The type of dependency. This defaults to jar. While it usually
represents the extension on the filename of the dependency, that is not always the case. A type can be mapped to a different extension and a classifier. The type often corresponds to the packaging used, though this is also not always the case.
Some examples are jar, war, ejb-client and test-jar
New types can be defined by plugins that set extensions to true, so this is not a complete list.
But next when you explicitly declare the parent pom to have the type as
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>${jboss-javaee-7.0.version}</version>
<type>pom</type><!--override the default value-->
<scope>import</scope>
</dependency>
</dependencyManagement>
the child module now either can inherit the dependency with the same <type> as
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<type>pom</type><!--inherited-->
</dependency>
OR if you want to utilize the jar of the project which is a different <type>, you can explicitly mention the dependency as :
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>${jboss-javaee-7.0.version}</version>
<type>jar</type> <!--different from parent-->
</dependency>
You are trying to import jboss-javaee-7.0 jar in your child project, there is no such jar, it is of type pom which you already importing in your parent.
You need to import dependencies of jboss-javaee-7.0 in your child project, some thing like.
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
</dependency>
You can get more information about importing dependencies
Related
I am using Maven to download aws-java-sdk dependency for version 1.11.23, though in Maven repository I find all historical versions till most recent ones; i.e. aws-java-sdk-sqs downloaded versions (1.9.0 to 1.11.642) any idea why is that and how can I limit to only the version specified for aws-java-sdk artifact?
This "dependency loop" is a problem with some older versions of aws-lambda-java-events, which is probably a dependency of your dependency.
Try updating or your dependencies to the latest, or overriding aws-lambda-java-events to at least 2.2.7:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>2.2.7</version>
</dependency>
For me, After specifying the BOM of AWS SDK in the dependencyManagement section & the version I would like to use, The historical downloads were stopped. Below are my dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.10.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
I created a project (with Maven 3.5.4) with just:
<project ... >
....
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.23</version>
</dependency>
</dependencies>
</project>
All of ~/.m2/repository/com/amazonaws/* (as declared in aws-java-sdks POM) contain just the sub-directory /1.11.23.
UPDATE
To exclude dependencies of your dependencies see Introduction to the Dependency Mechanism, Transitive Dependencies:
Excluded dependencies - If project X depends on project Y, and project Y depends on project Z, the owner of project X can explicitly exclude project Z as a dependency, using the "exclusion" element.
I have pom.xml like,
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>1.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
I am unable to understand why am I required to specify version on cdi-api under dependencies when it is already defined in microprofile (inside dependencymanagement).
This pom isn't a standard bom that would define version of the dependencies but must be used like a standard dependency: https://github.com/eclipse/microprofile-bom
This style of BOM does not go in a
dependencyManagement section, using import
scope, and you cannot add dependencies declared in the BOM without
version elements as is typically done with that style of BOM.
You actually need to depend on that pom:
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<type>pom</type>
</dependency>
Don't forget to add the type pom and either specify the version or reference this version in your dependency management with type pom if you want everything to work. glytching forgot the type pom, that's why this doesn't work.
The org.eclipse.microprofile:microprofile artifact declares a dependency on javax.enterprise:cdi-api so if you declare org.eclipse.microprofile:microprofile as a dependency in your POM then javax.enterprise:cdi-api will be provided transitively.
In the example in your question you declared org.eclipse.microprofile:microprofile in the <dependencyManagement> section, this section consolidates management of the version, scope, and exclusions for each dependency but in order to use that dependency in your project you must include it in the <dependency> section.
So, if you add this to your <dependency> section ...
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
</dependency>
... then org.eclipse.microprofile:microprofile will be included in your project and hence javax.enterprise:cdi-api will be included transitively and you won't have to declare it explicitly.
I have a Maven demo project for which I use some Spring Security features.
I could import the project fine into Eclipse STS and the editor shows no error related to dependencies.
But a Maven command to compile on the command line fails.
I get the following errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project learnintouch-web: Compilation failure: Compilation failure:
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[7,78] package org.springframework.security.config.annotation.authentication.builders does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[8,67] package org.springframework.security.config.annotation.web.builders does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[9,72] package org.springframework.security.config.annotation.web.configuration does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[10,72] package org.springframework.security.config.annotation.web.configuration does not exist
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[19,47] cannot find symbol
[ERROR] symbol: class WebSecurityConfigurerAdapter
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[15,2] cannot find symbol
[ERROR] symbol: class EnableWebSecurity
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[25,34] cannot find symbol
[ERROR] symbol: class AuthenticationManagerBuilder
[ERROR] location: class com.thalasoft.learnintouch.web.config.WebSecurityConfiguration
[ERROR] /home/stephane/dev/java/projects/learnintouch-web/src/main/java/com/thalasoft/learnintouch/web/config/WebSecurityConfiguration.java:[24,9] method does not override or implement a method from a supertype
Here is in the pom.xml the Spring Security dependencies:
<org.springframework.security.version>3.2.4.RELEASE</org.springframework.security.version>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
I resolved this by removing this line from pom.xml on the spring-security-config artifact:
<scope>runtime</scope>
You need to add spring security library manually.
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
I could solve this by adding the latest possible compatible versions of springframework.version and springsecurity.version.
Ex:
<properties>
<springframework.version>5.1.1.RELEASE</springframework.version>
<springsecurity.version>5.1.1.RELEASE</springsecurity.version>
</properties>
Also in the dependencies, I added the below:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.1.1.RELEASE</version>
</dependency>
Now it worked fine.
I overhauled the dependencies and the build now passes. There was some conflict between Spring dependencies.
I ran into the same issue going through some Spring Security tutorials. This is due to versioning conflicts.
Update your POM to remove the version info for all the Spring dependencies. Then throw in the spring-framework-bom to handle your versioning and it should work.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
in my case this error was caused by version conflict
had java 8 maven app , changed version to java7 and made mvn eclipse:eclipse
from cmd it was running but from eclipse giving error:
WebSecurityConfigurerAdapter cannot be resolved to a type
after project was showing all jars and work was not easy
security jars were not shown
was giving error : WebSecurityConfigurerAdapter cannot be resolved to a type
right click
from menu choose: configure -> convert to maven project
after right click project and choose properties->java build path :
check for java version ,remove incorrect java version
with button [add library] change to ide's java version
still in properties window choose: java compiler
compiler compliance level group
change to ide's java version
where it is showing incorrect version
that is it
It seems version conflict problem.
I faced same problem and could solve it by changing spring-security version from 3.1.7 to 3.2.4.
Hope it may help someone.
If you have spring boo project add following dependency ,Seems like Spring security jar is missing
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Isn’t the artifact name under below URL wrong?
http://repo1.maven.org/maven2/org/powermock/powermock-mockito-release-full/1.5.1/
As per above URL, The name of the artifact should have been powermock-mockito-release-full-1.5.1.jar but what I see is powermock-mockito-release-full-1.5.1*-full*.jar. The additional –full is breaking my maven build (unable to find resource). Below is my dependency declaration and how different I should declare the POM dependency than below one.
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
Am I missing something?
Thanks
The last full in this repository is another dependency coordinate called classifier.
Try adding the classifier and you should download the dependency:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.5.1</version>
<classifier>full</classifier>
<scope>test</scope>
</dependency>
I suggest to avoid classifier because their values are not standard and therefore their meaning and the way to use them is not always so clear.
Looking at the mockito site you should include the dependency like so:
http://code.google.com/p/powermock/wiki/Mockito_maven
<properties>
<powermock.version>1.5.4</powermock.version>
</properties>
<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
I have this maven hierachy :
sim-java
ejb
web
log4j
...
ejb, web and log4j are modules of sim-java and each of these modules refer to sim-java by parent tag.
I would like to create a log4j module and include it as dependency in sim-java so log4j will be present as dependency in ejb and web modules.
Basically, my pom.xml inside sim-java contains this :
<dependencies>
<dependency>
<groupId>com.sim</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
(scope is provided as I have an ear module which will include com.sim:log4j in ear file).
Now, my pom.xml inside my log4j module is this one :
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
I have this build error :
30/10/12 18:56:07 CET: Build errors for log4j; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project log4j: Could not resolve dependencies for project com.sim:log4j:jar:0.0.1-SNAPSHOT: Could not find artifact com.sim:log4j:jar:0.0.1-SNAPSHOT
I thought that there was some dependency problem since sim-java use com.sim.log4j as transitive dependency, so I tested that inside log4j pom.xml :
<dependencies>
<dependency>
<groupId>com.sim</groupId>
<artifactId>sim-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.sim</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
30/10/12 18:59:22 CET: [WARN] The POM for com.sim:log4j:jar:0.0.1-SNAPSHOT is missing, no dependency information available
30/10/12 18:59:22 CET: Missing artifact com.sim:log4j:jar:0.0.1-SNAPSHOT:provided
30/10/12 18:59:22 CET: Missing artifact com.sim:log4j:jar:0.0.1-SNAPSHOT:provided
30/10/12 18:59:22 CET: Missing artifact com.sim:log4j:jar:0.0.1-SNAPSHOT:provided
Perhaps including com.sim.log4j inside modules (ejb, web etc...) would work but I want to use transitive dependency via sim-java project.
How to do this please ?
Olivier
You cannot have the dependency on com.sim:log4j in the parent pom. That dependency will be inherited in the children meaning that com.sim:log4j will depend on itself.
Instead create a <dependencyManagement/> in the parent pom and then declare the use of com.sim:log4j in the children that needs it, here it is web and ejb.
Parent pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sim</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
Web and Ejb pom:
<dependencies>
<dependency>
<groupId>com.sim</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
Edit
You can still have a transitive dependency by only having the dependency on the log4j module from the ejb project. The web project will then have a dependency on the ejb project and the log4j will be a transitive dependency.