I'm working on a project with a parent maven module that contains no sources and 4 child modules.
It's supposed to be a Spring Application, the class having SpringApplication.run(XXX.class, args); is in a child module.
As I work with intelliJ community I don't have the spring plugin that could help me launch easely the application.
If I clean install the project everything builds correctly.
To start the application i try to right click on the class booting Spring and then click on run.
As intelliJ tries to build the app i get the following message :
Failed to execute goal on project XXX : Could not resolve dependencies
for project XXX:XXX:jar:0.0.28: Failed to collect dependencies at
XXX:XXX:jar:0.0.28: Failed to read artifact descriptor for
XXX:jar:0.0.28: Could not transfer artifact XXX:YYY:pom:${ZZZ_version_module} from/to
releases (http://nexus...): Authorization failed for
http://nexus.../.../.../$%257BZZZ_version_module%257D/...-$%257BZZZ_version_module%257D.pom
403 Forbidden
From what i understand the problem is that when building, intelliJ only build the child module, so it cannot turn the variablized version in my pom.xml ${ZZZ_version_module} into the right version using properties from the parent pom.
Because of my work, I cannot use any plugin in intelliJ or any other dependency in my pom that could help me.
Do any one have any solution to run the SpringApplication ?
Parent 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 https://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>2.4.3</version>
</parent>
<groupId>ABC</groupId>
<artifactId>XYZ</artifactId>
<version>${ZZZ_version_module}</version>
<packaging>pom</packaging>
<name>...</name>
<description>...</description>
<properties>
<ZZZ_version_module>0.0.28</ZZZ_version_module>
...
</properties>
</project>
Child 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ABC</groupId>
<artifactId>XYZ</artifactId>
<version>${ZZZ_version_module}</version>
</parent>
<artifactId>...</artifactId>
<name>...</name>
<description>...</description>
</project>
(Sorry for the broken english)
Related
I'm following a course that implementes Java EE standards using the Vaadin framework, Maven, Spring Boot and JPA.
I have succesfully deployed my Maven project + modules to a Jboss WildFly Server.
A minor error that is ocurring is: in the course, the application URL is
http://localhost:8080/univers-web/*
but when I compile and run the application I have to type:
http://localhost:8080/univers-web-1.3.6.RELEASE
Is a minor annoyance ,but is there a way to remove the project version from the URL name?
I checked the pom.xml file and here is the starting snippet of code:
<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>univers-web</artifactId>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<version>1.3.6.RELEASE</version>
<artifactId>spring-boot-starter-parent</artifactId>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
.
.
.
</project>
In the build section of your pom, add <finalName>univers-web</finalName>.
I have a question about my maven configuration on my MAC Intellij. I get an error that ${a-web.version} "properties in parent definition are prohibited" within parent tag in child POM.xml and that properties is defined in parent POM.xml.
But this same configuration works well on my Windows Intellij.
Below is my parent 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>***</groupId>
<artifactId>a-web</artifactId>
<packaging>pom</packaging>
<version>${a-web.version}</version>
<name>a-web project</name>
<url>http://***</url>
<properties>
<a-web.version>1.0.0</a-web.version>
</properties>
<modules>
<module>a-core</module>
<module>a-web</module>
</modules>
</project>
And this is my child POM.xml that configure a parent block.
<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>
<artifactId>a-web</artifactId>
<groupId>***</groupId>
<version>${a-web.version}</version>
<relativePath>../</relativePath>
</parent>
<artifactId>aweb-web</artifactId>
<version>${a-web.version}</version>
<packaging>war</packaging>
<name>aweb-web</name>
</project>
I've tried many methods from stackoverflow, but no one can fix it. I want to know why this Maven config have different behaviour in Mac and windows and how to fix it.
I have run into a very similar situation when the project started using parent version properties in the commit I have just pulled. The project would not build and felt "ill-imported". An attempt to show effective pom failed with no details presented by IDEA.
As #khmarbaise pointed out in the comments[1], there are some restrictions for properties usage in maven <parent> declarations - the most notable is maven 3.5+ is required. The IDEA might not be using maven new enough (the bundled one in the latest IDEA I have installed was too old) so I had to switch to local install using Settings > Build, Execution, Deployment > Build Tools > Maven > Maven Home Directory. Once pointed to newer version, it did not start to work immediately - some of the restart/rebuild/reimport routines caused the new setting to be effective and the project to successfully import and build again.
Despite the maven version requirement was enforced in pom, it have not caused IDEA to complain the maven version it uses is old. The lack of any details that IDEA fails to inspect the project with the maven it uses did not helped either. Now when everything else works, it still says "Properties in parent definition are prohibited" in pom files.
[1] https://maven.apache.org/maven-ci-friendly.html
Setting property revision in parent pom.xml and then inherit it into children, fixed the issue for me.
<groupId>com.java</groupId>
<artifactId>test</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>Test</name>
<description>Demo project for Spring Boot</description>
<modules>
<module>backend</module>
<module>frontend</module>
</modules>
<properties>
<revision>1.0.0-SNAPSHOT</revision>
</properties>
In the child's pom.xml:
<parent>
<artifactId>com.java</artifactId>
<groupId>test</groupId>
<version>${revision}</version>
</parent>
<artifactId>backend</artifactId>
I use Maven 3.6.1
Work for me in Idea 18.2:
1) Don't use embeded Maven. Install Maven from official site! It's help me (^_^)
2) You can try to add groupId in child pom, put <groupId>com.iqiyi.lego.web</groupId> before line <artifactId>legoweb-web</artifactId>.
Try this code:
<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>
<artifactId>lego-web</artifactId>
<groupId>com.iqiyi.lego.web</groupId>
<version>${lego-web.version}</version>
<relativePath>../</relativePath>
</parent>
**<groupId>com.iqiyi.lego.web</groupId>**
<artifactId>legoweb-web</artifactId>
<version>${lego-web.version}</version>
<packaging>war</packaging>
<name>legoweb-web</name>
</project>
because your maven version is lower than 3.5.2, try to use version that >=3.5.2,when the ide intellij idea bundled maven version is lower than 3.5.2,try to download zip set to use your own maven instead of the bundled one.
by the way,although maven lower than 3.5.2 show error in intellij idea,but it works ok,you can "mvn package" success.
I think it's because when you push the compiled jar to central maven or private maven such as nexus, you can find the version in META-INF/maven/xxxxx/pom.xml of sub project is
<version>${lego-web.version}</version>
not real value <version>1.0.0</version>.so when you want to release a single jar, you cannot get the true version
It is the IntelliJ IDEA bug.
At least in the IntelliJ IDEA 2019.2 (Ultimate Edition)
Build #IU-192.5728.98, built on July 23, 2019
I have a maven project that contains two submodules, one depends on there other.
The project has no code but maven is ok with that. If I perform mvn package it passes ok and generates (empty) jar files.
However if I do mvn dependency:list I get the following error:
Failed to execute goal on project foob-two: Could not resolve dependencies for project com.example.foob:foob-two:jar:1.0.0-SNAPSHOT: Failure to find com.example.foob:foob-one:jar:1.0.0-SNAPSHOT in [Repo]
It seems like the maven dependency plugin only works after the modules have been uploaded to the local repo.
Strangely if I do the dependency list at the same time as package, ie mvn package dependency:list, it works. So it seems that maven has a different dependency resolution mechanism in some contexts.
Can anyone explain the behaviour? Can I run mvn dependency:list as a standalone command?
Here's the root 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.example.foob</groupId>
<artifactId>foob</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>foob-one</module>
<module>foob-two</module>
</modules>
</project>
Here's the first subproject:
<?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">
<parent>
<groupId>com.example.foob</groupId>
<artifactId>foob</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foob-one</artifactId>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project>
Here's the second project:
<?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">
<parent>
<groupId>com.example.foob</groupId>
<artifactId>foob</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foob-two</artifactId>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>com.example.foob</groupId>
<artifactId>foob-one</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
mvn dependency:list can be run on its own. It appears as if your project is failing because of missing dependencies. Try mvn install first.
how to make one module depends on another module artifact in maven multi-modules
When running commands such as
mvn dependency:build-classpath
or
mvn exec:java
Maven is unable to resolve a dependency of one of my modules on another.
[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT
The project structure is as follows:
/pom.xml
/A/pom.xml
/B/pom.xml
The parent pom is as follows:
<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_group</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>parent</name>
<modules>
<module>A</module>
<module>B</module>
</modules>
The first child module (the one failing to resolve the dependency):
<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>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>
<dependencies>
<dependency>
<groupId>parent_group</groupId>
<artifactId>B</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
The second child module (the dependency):
<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>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>jar</packaging>
<name>B</name>
Have you run mvn clean install at least once on the project to install the dependencies within your local repository?
The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).
Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.
A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.
As an example you can combine the task you want with the 'compile' or 'package' tasks.
Also see highest voted answer at
Maven doesn't recognize sibling modules when running mvn dependency:tree
This error might also be caused by Maven being in offline mode.
Sometimes I seem to accidentally enable offline mode in IntelliJ IDEA. To disable it, toggle the Toggle Offline Mode toggle in the Maven Toolbar
or uncheck the Work Offline checkbox in the settings under Build, Execution, Deployment > Build Tools > Maven.
Configuring test-jar in the jar plugin resolved the issue for me:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Afterwards, running mvn clean install works.
I am trying to create a maven multi-module project. the project is created successfully but when I am trying to use one module as a dependency of another module, it throws an exception. When I create a module using eclipse, I was selecting packaging as a jar, but when the module is created, the packaging tag was not mention in child pom.xml and I manually insert the packaging tag as a jar.
following is my parent 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.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
-------------------------
<modules>
<module>empirecl-web</module>
<module>empirecl-dao</module>
<module>empirecl-service</module>
<module>empirecl-api</module>
</modules>
Dao Child Module:
<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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-dao</artifactId>
<packaging>jar</packaging>
<name>empirecl-dao</name>
------------------------
Service Child Module:
<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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-service</artifactId>
<packaging>jar</packaging>
<name>empirecl-service</name>
<dependencies>
<dependency>
<groupId>com.netsol</groupId>
<artifactId>empirecl-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
------------------------------------------
The Dao module maven clean and install successfully, but when i trying to use service module, it will generate an following exception:
[ERROR] Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Could not find artifact com.netsol:empirecl:pom:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT
I am trying the find to solution from web, but still the solution is not found. In eclipse when i open the Dependency Hierarchy of service module, it shown the DAO module as a folder not jar. below is the screen shot of Dependency Hierarchy of service module.
In case anybody comes back to this, I think the problem here was failing to install the parent pom first, which all these submodules depend on, so the Maven Reactor can't collect the necessary dependencies to build the submodule.
So from the root directory (here D:\luna_workspace\empire_club\empirecl) it probably just needs a:
mvn clean install
(Aside: <relativePath>../pom.xml</relativePath> is not really necessary as it's the default value).
In my case I forgot it was packaging conflict jar vs pom. I forgot to write
<packaging>pom</packaging>
In every child pom.xml file
My solution was to insert <packaging>pom</packaging> between artifactId and version
<groupId>com.onlinechat</groupId>
<artifactId>chat-online</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>server</module>
<module>client</module>
<module>network</module>
</modules>
This what worked for me -
Go to Java build path --> Order and Export(check JRE system libraries and maven dependencies) in my case these 2 were unchecked.
My solution:
remove all projects in current workspace
import all again
maven update project (Alt + F5) -> Select All and check Force Update of Snapshots/Releases
maven build (Ctrl + B) until there is nothing to build
It worked for me after the second try.
For me, adding the following block of code under <dependency management><dependencies> solved the problem.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b06</version>
</dependency>
Check with your VPN connection, if you are working in home.
Delete or close all other projects, and restart netbeans IDE, and try again.