Maven module as dependency on a Web Application - java

ich have tree modules for my projec, server,client and core. Core module should be imported as jar dependency in other modules.
On eclipse i see no warnings, but if i'm starting the application i'm getting following error :
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [at.ac.tuwien.inso.verteilte.service.HelloServiceImpl] for bean with name 'helloServiceImpl' defined in ServletContext resource [/WEB-INF/appContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: at/ac/tuwien/inso/verteilte/services/IHelloService
Caused by: java.lang.ClassNotFoundException: at.ac.tuwien.inso.verteilte.services.IHelloService
this interface is imported on a HelloServiceImpl. HelloServiceImpl is created on the beans as following :
<jaxws:endpoint id="helloService" implementorClass="at.ac.tuwien.inso.verteilte.service.HelloServiceImpl">
i have removed the namespaces because of link protection of stackoverflow :)
By the way, my pom.xml's are :
for core :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core</name>
<packaging>jar</packaging>
<description>Verteilte Praxen - core</description>
<build>
<finalName>core-1.0-SNAPSHOT</finalName>
</build>
</project>
Server :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>server</name>
<description>Verteilte Praxen - Server</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>server-1.0-SNAPSHOT</finalName>
</build>
</project>
Client :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>client</name>
<description>Verteilte Praxen - Client</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>client-1.0-SNAPSHOT</finalName>
</build>
</project>
And the parent pom :
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>verteiltepaxen-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>verteiltepaxen Maven Webapp</name>
<properties>
<cxf.version>2.2.3</cxf.version>
<spring.version>2.5.6.SEC02</spring.version>
</properties>
<dependencies>
... other dependencies ...
</dependencies>
<repositories>
... Repositories ...
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectNameTemplate>verteiltepaxen-parent-1.0-SNAPSHOT</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.8</version>
<configuration>
<!-- Configure the webapp -->
<contextPath>/verteiltepaxen</contextPath>
</configuration>
</plugin>
</plugins>
<finalName>verteiltepaxen-parent-1.0SNAPSHOT</finalName>
</build>
<modules>
<module>client</module>
<module>server</module>
<module>core</module>
</modules>
</project>
Thanks you very much for your helps :)
Thank your for your help, i've removed it but the error is the same
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>

I'm not sure what this would actually do, but in the server's POM you are listing core as a dependency and then also excluding it:
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>
Why would you do this? Exclusions are used to tell Maven to ignore some dependencies dragged in by other dependencies in your build.Try removing the exclusion.

You likely just need a mvn clean install in the parent directory to get a fresh war file. Otherwise, clarify what you mean by "if i'm starting the application": using the maven jetty plugin? Deploying to Tomcat? Something else?

Related

Creating Maven dependency of Project A and using it in Project B

I have a maven Spring boot project for which I've created a jar to use as a dependency externally in other projects. I just can't get it to work. Here are my steps.
Here is my pom.xml for Project 1.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp.logmonitoring</groupId>
<artifactId>logmonitoring</artifactId>
<name>logmonitoring</name>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.4.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>logmonitoring/logmonitoring-app</finalName>
</configuration>
</plugin>
</plugins>
</build>
And this is my pom.xml for Project 2. It just doesn't work.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp.logmonitoring.host1</groupId>
<artifactId>logmonitoring-host1</artifactId>
<name>logmonitoring-host1</name>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.myapp.logmonitoring</groupId>
<artifactId>logmonitoring</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
You have to put Jar as well as pom file of 1st project in.m2 repository.
.m2/org/myapp/logmonitoring/1.0-SNAPSHOT.
then add dependency like this
<dependency>
<groupId>org.myapp</groupId>
<artifactId>logmonitoring</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
If you are using mac then you can find .m2 repository in
/Users/<user_name>/.m2.
In Windowns it's in
C:\Users<User_Name>.m2
In linux it's in
/home/<User_Name>/.m2
Also unhide Hidden files
This really helped me solve it - http://www.avajava.com/tutorials/lessons/how-do-i-add-a-project-as-a-dependency-of-another-project.html

Package multi module maven with nested modules

I have the following maven project structure
Project[pom.xml] <type>pom</type>
-module 1[pom.xml] <type>jar</type>
-module 2[pom.xml] <type>pom</type>
--SubModule1[pom.xml] <type>jar</type>
--SubModule2[pom.xml] <type>jar</type>
--SubModule3[pom.xml] <type>war</type>
-module 3[pom.xml] <type>ear</type>
my problem with the packaging, the output EAR file does not include module 2 when doing
mvn clean install
What I did in module 2 is to package as war. but then I could not the artifact to the ear file.
any ideas are appreciated.
I hope I am not congesting this question
below is the poms
Project 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project</groupId>
<artifactId>project</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>project</name>
<description>Insert description for your project here.</description>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<!--Configuration of the maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<inherited>true</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Module 2 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>
<parent>
<groupId>project</groupId>
<artifactId>project</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>module2</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>SubModule1</module>
<module>SubModule2</module>
<module>SubModule3</module>
</modules>
<properties>
<!--suppress UnresolvedMavenProperty -->
<context.root>/root</context.root>
<!--suppress UnresolvedMavenProperty -->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>project</groupId>
<artifactId>SubModule1</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>project</groupId>
<artifactId>SubModule2</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>project</groupId>
<artifactId>SubModule3</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>project</groupId>
<artifactId>SubModule3</artifactId>
<contextRoot>${context.root}</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
*** module3 EAR ***
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>project</groupId>
<artifactId>project</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>module3</artifactId>
<packaging>ear</packaging>
<description>This is the EAR POM file</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module2</artifactId>
<type>pom</type>
</dependency>
</dependencies>
<build>
<finalName>${project.parent.artifactId}</finalName>
<plugins>
<!--EAR plugin: format of output file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<version>8</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
</modules>
<outputFileNameMapping>#{artifactId}##{dashClassifier?}#.#{extension}#</outputFileNameMapping>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
The following declarations in the parent POM seem strange:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module2</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
They might cause the described problems.

Tree Component in Vaadin latest version doesn't work

I trying to use the Tree() method with last version of Vaadin inside my maven project with spring-boot to create a drop down simple menu, but I can't import the correct packages.
I just have these dependencies in my pom.xml file:
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<groupId>spring.boot.vaadin.admin</groupId>
<artifactId>spring.boot.vaadin.admin.ui</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>spring-boot-vaadin-admin-ui-components</warName>
</configuration>
</plugin>
</plugins>
<finalName>spring-boot-vaadin-admin-ui-components</finalName>
</build>
<packaging>war</packaging>
</project>
This is the error:
What should I do to use Tree() on the latest version of Vaadin and solve this error?
Tree component is not fully ready for Vaadin 8 yet. You must use vaadin-compatibility-server package if you want to use it.
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-server</artifactId>
<version>8.0.2</version>
</dependency>

Maven sibling dependency issue in a multi module project

I have a multi module project with 1 main module (engine) and 2 sub modules (client and server)
engine (Main module)
- Client
- Server
When I try to use the server module in the client, It throws a compilation error that indicates that the server package was not found.
Please find all the 3 POM's below.
Engine 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>dev.kasse</groupId>
<artifactId>engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>server</module>
<module>client</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
Client 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>
<parent>
<groupId>dev.kasse</groupId>
<artifactId>engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>client</artifactId>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
**<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>server</artifactId>
<scope>test</scope>
<version>${project.version}</version>
</dependency>**
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>0</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
Server 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>
<parent>
<groupId>dev.kasse</groupId>
<artifactId>engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>server</artifactId>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Your modules need
<packaging>jar</packaging>
to overwrite the
<packaging>pom</packaging>
from the parent file.
I have a similar project set-up, but your solution worked just fine for me.
Still one way that could maybe have solved it in your case, would be to define the version in the parent pom using the dependencyManagment
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${groupId}</groupId>
<artifactId>server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
The dependency to the server has "test" scope: this means that is will be not included in the runtime package
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>server</artifactId>
<scope>test</scope> <!-- remove this tag -->
<version>${project.version}</version>
</dependency>
for more information on dependency scopes see: here
Ran into a similar problem. This seems to be caused by spring boots' packaging of jar. The Spring boot create an executable jar, sending the classes into BOOT-INF folder inside the jar.
Adding the following into the build\plugins section of the pom resolves the issue (client pom in the case here)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<forceCreation>true</forceCreation>
</configuration>
</execution>
</executions>
</plugin>
An alternative solution is here : Maven Multi-module dependency package not found

Using Maven Versions Plugin

Using the following command line:
mvn versions:unlock-snapshots dependency:copy-dependencies
I get all snapshot jars with the SNAPSHOT.jar name in the dependency folder.
Why do I don't get the same behavior when packaging my project into a war?
Instead of getting mylibs-modules-1.0-SNAPSHOT.jar, I get those incrementing numbers.
EDITED
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>mylibs</artifactId>
<packaging>war</packaging>
<version>3.4</version>
<parent>
<groupId>parent</groupId>
<artifactId>mylibs-parent</artifactId>
<version>3.4</version>
</parent>
<build>
<finalName>mylibs-war</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
</build>
PARENT POM FILE
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>parent</groupId>
<artifactId>mylibs</artifactId>
<packaging>pom</packaging>
<version>3.4</version>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-tests</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-processor</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-persistence</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-databean</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-localization</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-net</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-lang</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-metadata</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-events</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-logging</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
The plugin goal is not designed to be run as part of the lifecycle per the documentation. The Attributes section describing the unlock-snapshots goal says
Executes by direct invocation only.
This means it will only run if you type mvn versions:unlock-snapshots at the command line as you have been doing.
Just noted the comment above about how the commands are run:
mvn versions:unlock-snapshots package
I suspect this doesn't work because the unlock-snapshots goal is actually changing the POM, however the package phase is running with the original, unmodified version of the POM. Perhaps running the build with -X will show this.

Categories

Resources