Maven dependencyManagement WARNING on clean project generated from start.spring.io - maven

I'm creating a Spring Boot 1.5.1 project from start.spring.io including the following dependencies: Web, HATEOAS, Stream Kafka, Zookeeper Configuration, Zookeeper Discovery, Actuator. The service itself is a spring-cloud-stream test service.
Without changing anything from the generated code, at mvn package I got the following message. It's just a warning, but since compiling other maven project I'm getting build problems in other projects I'd like to solve it. (I tried to isolate the problem by creating this clean project from start.spring.io).
This is the exact Warning log, and below the generated pom.xml. Notice that the dependencyManagement warning mentions com.netflix.eureka, but in this project no Eureka dependencies have been included.
I also tried to remove all contents from the local maven repository and rebuild, to make sure this is in a consistent state but kept getting the warning.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for eu.myapp.services.testsource:test:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId' for com.netflix.eureka:eureka-core:jar with value '*' does not match a valid id pattern. # org.springframework.cloud:spring-cloud-netflix-dependencies:1.3.0.BUILD-SNAPSHOT, /home/vagrant/.m2/repository/org/springframework/cloud/spring-cloud-netflix-dependencies/1.3.0.BUILD-SNAPSHOT/spring-cloud-netflix-dependencies-1.3.0.BUILD-SNAPSHOT.pom, line 273, column 19
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
here the 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">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.myapp.services.testsource</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</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-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

The issue comes from https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-dependencies/pom.xml#L273-L276
I've opened an issue here. https://github.com/spring-cloud/spring-cloud-netflix/issues/1715

it's very likely that the dependency is being used by another dependency I recommend you first find the issue by doing a search on your dependency tree.
mvn dependency:tree
looks like spring-cloud-starter-zookeeper-discovery might be the culprit
https://cloud.spring.io/spring-cloud-zookeeper/
now it's just a matter of finding what is excluding it. What you do next might get tricky because if you exclude it, zookeeper might now work anymore

Related

How to access parent pom properties in spring boot project

This is my spring boot pom ,
<?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>
<groupId>com.piggymetrics</groupId>
<artifactId>gateway</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gateway</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.cc.cmt.ccc</groupId>
<artifactId>cc.ccme</artifactId>
<version>${cc.cmt.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.M4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
I have a parent pom ,which contain one properties version ${cc.cmt.version} ,How could I access this ?
The problem you want to deal with has more to do with Maven itself than of Spring Boot. If my assumption is right, you're likely in following situation
ModuleA
ModuleB
ModuleC
where, as depicted, say, there're three Maven modules in your Spring Boot project. You'd like to inherit ModuleA in the pom.xml of ModuleB and both of them needs to have Spring Boot parent dependency.
Maven project's can't have multiple parents declared in one pom.xml. Having said that, the workaround here is to declare org.springframework.boot parent dependency at ModuleA first along with all other property values. Now, just declare ModuleA as parent in the pom.xml of ModuleBand ModuleB will be able to access all dependencies(Spring Boot+others) as well as properties declared in ModuleA's pom.xml.

Service Registration and Discovery Eureka Server start up issue

I am getting the following error while trying to start the eureka server.The apache commons config lib is showing in the maven lib section on the project.
Have tried using the same pom file as given in the following URL
https://spring.io/guides/gs/service-registration-and-discovery/
java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration
at org.springframework.cloud.netflix.eureka.server.EurekaServerBootstrap.initEurekaEnvironment(EurekaServerBootstrap.java:111) ~[spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.cloud.netflix.eureka.server.EurekaServerBootstrap.contextInitialized(EurekaServerBootstrap.java:82) ~[spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$1.run(EurekaServerInitializerConfiguration.java:71) [spring-cloud-netflix-eureka-server-2.0.0.M7.jar:2.0.0.M7]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration
I am attaching the pom.xml which I am using
<groupId>com.example</groupId>
<artifactId>eureka-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.M8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
This could very well be due to apache commons-configuration missing or incompatible transitive dependency.
I would suggest you analyze the dependency tree using mvn:dependency
tree and identify the commons-configuration version.
You might want to explicitly add the latest maven
commoins-configuration in your pom
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.9</version>
</dependency>

Unable to deploy jar from a Spring Boot application to Nexus/Artifactory

Deploying to my local artifactory/nexus with maven works fine for sample Spring Boot applications (generated on start.spring.io):
mvn clean package deploy
However as soon as I add a dependency from org.springframweork.cloud to my pom:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
then the deploy fails with "Connection reset" on the client side. artifactory.log shows
2017-02-07 12:57:59,788 [http-nio-8081-exec-10] [INFO ] (o.a.e.UploadServiceImpl:516) - Deploy to 'snapshot-local:com/test/artifactory-demo/0.0.1-SNAPSHOT/artifactory-demo-0.0.1-20170207.125744-10.jar' Content-Length: 21658959
2017-02-07 12:58:03,256 [http-nio-8081-exec-10] [WARN ] (o.a.w.s.RepoFilter :222) - Sending HTTP error code 404: Failed to read stream: Unexpected EOF read on the socket
2017-02-07 12:58:59,540 [http-nio-8081-exec-2] [WARN ] (o.a.w.s.RepoFilter :222) - Sending HTTP error code 404: Failed to read stream: null
I have noticed similar behaviour with Nexus. I also get the same error if I try and upload the jar using Artifactory UI. Funny enough if I extract the jar file using:
jar xf demo.jar
and then zip it back again changing the flague changing the flague to "cf" then this newly packaged jar can successfully be uploaded to Artifactory. It seems like Maven is doing something funny with the jar at the build step. Does anyony have any idea what I could be doing wrong? Having to extract and repackage the jar before deploying it is far from ideal, especially that I would like to do it for a number of projects automatically with Jenkins.
Below is the entire not working 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">
<modelVersion>4.0.0</modelVersion>
<artifactId>artifactory-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>artifactory-demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jfrog.artifactory.client</groupId>
<artifactId>artifactory-java-client-services</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.M1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>snapshots</name>
<url>http://artifactory.server.ip:8079/artifactory/snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
It turned out to be a weird issue with our on-premise infrastructure. The server was simply dropping the connection, so I temporarily put my Nexus on the same machine as our CI application

Missing artifact when trying to add spring-data

I am trying to add the spring data dependency to my Spring boot starter project but I am getting the error: Missing artifact org.springframework.data:spring-data-jdbc-ext:jar:1.0.0.RELEASE
Here is my pom.xml file. What am I missing here?
<?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>
<groupId>com.test</groupId>
<artifactId>myApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC1</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-ext</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
</dependencies>
<properties>
<start-class>com.test.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
For some reason the documentation on the Spring Data JDBC Extensions website is wrong (or the distribution is wrong!).
According to that page you, indeed, need to include the dependency you mention.
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-ext</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
However if you take a look in the spring repository for that artifact it contains a zip file with the release instead of a jar or pom file.
The spring-data-jdbc-ext project consists of 2 artifacts, which both are available. Change your dependency to the following
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-core</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-oracle</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
If you don't need the specific Oracle extensions than you could leave that one out.
A small note there is a 1.1.0.M1 version also (a milestone/pre-release versio) which works with a newer version of Spring Data. You might want to try that instead of the 1.0.0.RELEASE version which was build against an older version of Spring Data.

Cannot read jenkins maven dependencies

I am trying to get this demo application up and running on my machine:
https://github.com/jenkinsci/cli-channel-demo
I have this in my pom:
<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>org.jenkins-ci.demo</groupId>
<artifactId>cli-channel-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cli-channel-demo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>cli</artifactId>
<version>1.415</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
But I get this error:
The POM for org.jenkins-ci.main:cli:jar:1.415 is missing, no dependency information available
even though the dependency is located right here:
http://repo.jenkins-ci.org/public/org/jenkins-ci/main/cli/1.415/
and I have this in my pom:
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
Why can't maven resolve this dependency on my local machine?
Worked fine on my machine. I think you need to supply some more details of your error.
Common issues are:
Network proxy denying direct access to internet
Mirror configuration pointing builds at a local Maven repository
See the Maven settings reference for more details on how these issues could be fixed.

Resources