Hi I'm working on project which created in netbeans 8.0.1.
It is created in Maven.Now after completion when try to open created jar its not getting executed.
below is the pom.xml file.
Please advise.
<?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.elitechweb.asm</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
</build>
</project>
Added maven-install-plugin-2.3.1 jar file. and changes in POM.xml respective jar
Related
We are upgrading project from Java 8 to Java 11, and facing the below error:
The package javax.xml.namespace is accessible from more than one module: <unnamed>, java.xml
Apparently, this is due to same package which is existing in another jar file is creating a problem. In order to fix this issue, we have excluded the jar time temporarily and it is working fine.
Is there a way that we can ignore this error without removing the transient dependencies. Since we have 200+ services and excluding from each service is a mammoth effort.
My pom.xml as below:
<?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>com.xyz</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mule.version>3.9.0</mule.version>
<mule.tools.version>1.2</mule.tools.version>
<apikit.version>3.9.0</apikit.version>
<munit.version>1.1.0</munit.version>
<mule.munit.support.version>3.7.1</mule.munit.support.version>
<java.version>11</java.version>
<junit.version>4.9</junit.version>
<jackson.version>2.8.5</jackson.version>
<httpcore.version>4.4.5</httpcore.version>
<spring.version>4.3.2.RELEASE</spring.version>
</properties>
<build>
<finalName>somename</finalName>
</build>
</project>
I have the following plain pom running by Maven 3.0.4.
<?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</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
I am trying to override default settings in command line like this:
mvn -Dproject.build.finalName=build clean package
But this this is ignored, and I get test-1.0.jar. I've tried to change another properties, like outputDirectory, directory, artifactId, but also failed.
What is the proper way to do this thing?
See Introduction to the POM
finalName is created as:
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
One of the solutions is to add own property:
<properties>
<finalName>${project.artifactId}-${project.version}</finalName>
</properties>
<build>
<finalName>${finalName}</finalName>
</build>
And now try:
mvn -DfinalName=build clean package
I have a project with two modules in that. The parent POM looks like this:
<?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>org.example</groupId>
<artifactId>bc</artifactId>
<packaging>pom</packaging>
<version>1.3-SNAPSHOT</version>
<modules>
<module>njoy</module>
<module>api</module>
</modules>
</project>
The njoy module POM looks like this:
<?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>
<artifactId>bc</artifactId>
<groupId>org.example</groupId>
<version>1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>njoy</artifactId>
<packaging>jar</packaging>
</project>
The api module POM looks like this:
<?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>
<artifactId>bc</artifactId>
<groupId>org.example</groupId>
<version>1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api</artifactId>
<packaging>jar</packaging>
</project>
I have done mvn clean install for the parent POM so that it gets into my local m2 repository.
Now i want to use this project as a dependency in another project(say experiments) by providing it as dependency.
These are the folders created in my m2 repo.
This is my other project where i am using it as a dependency, and the POM for it looks like this:
<?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>org.example</groupId>
<artifactId>experiments</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>bc</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>klk</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
But it cannot find the multi-module project artifact, where there is another dependency which is a single module project(klk) and there is no issue.
Please help. What am i missing here?
Thanks in advance!!
The artifact bc is just a pom with some modules. It cannot be used as a dependency. You probably thought you can reference "all artifacts" by referencing the parent POM. This is not possible.
The artifacts njoy and api are jars -- they can be used as a dependency of another project.
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
I am doing a Maven project with Intellj Idea in which I am trying to use neo4j.
I have an error of "unable resolve symbol neo4j" on (import org.neo4j.driver.v1.*;).
I have brought in the neo4j jar files to the project and believe I have a correctly set up pom file. I will post both though with this question below.
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</groupId>
<artifactId>NeoImport</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>NeoImport</name>
<description>Import</description>
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
</build>
</project>
Project Setup:
Thanks!