I run "mvn install" in command line and get stuck by below error.
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.detux.vios:common-entity:jar:2_0_0:
Could not find artifact org.hibernate:hibernate-entitymanager:jar:3.6.2.FINAL in central (http://repo.maven.apache.org/maven2)
I check in m2\repository\org\hibernate\hibernate-entitymanager\3.6.2.FINAL\, here is its contents
I've also tried to add new remote repository to pom.xml but it still 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>common</artifactId>
<groupId>com.detux.vios</groupId>
<version>2_0_0</version>
</parent>
<groupId>com.detux.vios</groupId>
<artifactId>common-entity</artifactId>
<version>${common.version}</version>
<name>Vios Common entity</name>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>com.detux.vios</groupId>
<artifactId>common-util</artifactId>
<version>${common.version}</version>
</dependency>
</dependencies>
<properties>
</properties>
<repositories>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>
</project>
Below is pom.xml of parent project
<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.detux.vios</groupId>
<artifactId>common</artifactId>
<version>2_0_0</version>
<packaging>pom</packaging>
<name>Vios Common</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-test-classes</id>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<commons-jxpath.version>1.3</commons-jxpath.version>
<common.version>2_0_0</common.version>
<spring.version>3.0.5.RELEASE</spring.version>
<spring.integration.version>2.0.4.RELEASE</spring.integration.version>
<hibernate.version>3.6.2.FINAL</hibernate.version>
<maven-jaxb2-plugin.version>0.7.4</maven-jaxb2-plugin.version>
<commonsbeanutils.version>1.8.3</commonsbeanutils.version>
<commons-lang.version>2.6</commons-lang.version>
</properties>
<modules>
<module>common-model</module>
<module>common-entity</module>
<module>common-storage</module>
<module>common-util</module>
<module>common-service</module>
<module>common-service-business</module>
<module>common-service-resource</module>
<module>common-catalog</module>
<module>common-xml-jaxb2</module>
</modules>
</project>
I am not sure how this could have happened, but the central has this artifact but with Final in its folder path and not FINAL.
Can you change your pom.xml to use Final and delete the existing local repository folder m2\repository\org\hibernate\hibernate-entitymanager\3.6.2.FINAL so that it can download again?
Related
I have the following code.
I am trying to create a 'pom.xml' file for a bukkit plugin (Minecraft) using Maven.
However, this gives me the error: 'The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.6 is missing'.
I have tried to trouble shoot a few different solutions but haven't been successful in any.
I would be so grateful for a helping hand!
<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>newestfile.here</groupId>
<artifactId>newestplugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.6</version>
<configuration>
<source>19</source>
<target>19</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The source and target look wrong, are you sure they shouldn't be 1.8? That is the only number I see listed. Double check that and try running mvn compile and see if that didn't fix it.
I changed the version to 3.10.1 and the target to 17 as follows, and the code successfully ran:
<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>newestfile.here</groupId>
<artifactId>newestplugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Thanks so much for all your help!
maven-compiler-plugin doesn't have 3.8.6 version. You need to choose some other version. Here is the available version list https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin.
I have just updated eclipse to Version: 2022-06 (4.24.0), and have the next exception in problems view (in pom.xml file):
Exception java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties [in thread "Worker-27: Building"]
The pom.xml file contains:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
...
</parent>
<artifactId>xxxx</artifactId>
<packaging>war</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
...
</dependencies>
<repositories>
<repository>
...
</repository>
</repositories>
<build>
<finalName>xxxx</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
No problems when generating maven artifactory.
Any idea how to avoid these error?
the solution is modify maven-war-plugin adding version 3.3.2:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
thanks
I am trying to publish a Java library to artifactory using Jenkins. Currently, it is only publishing .jar files to artifactory. I have a binary file (.bin) that I want to publish along with the .jar files. Does anyone know what I need to insert into my POM file to make this work?
For example, I want file structure in artifactory to look like this:
test-0.1.jar
test.bin
...
Here is my POM file:
<?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.github.test</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<name>Test Lib </name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- Avoid Java 8's strict doc generator-->
<profiles>
<profile>
<id>disable-java8-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The build helper maven plugin allows you to attach additional artifacts, see
https://www.mojohaus.org/build-helper-maven-plugin/usage.html
under "Attach additional artifacts to your project" or
https://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html
I have a maven project in which I'm trying to get a jar from a remote repository and add it to my local repository. After adding instead of referring its class, I need to run that jar which acts as a input for my current project.
I tried, and there are no build issues, but still it is not triggering to run the dependency.
My 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>secmaven</groupId>
<artifactId>secmaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>secmaven</name>
<description>secmaven</description>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>exec-one</id>
<phase>verify</phase>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
</executableDependency>
<!-- Look up the main class from the manifest inside your dependency's JAR -->
<mainClass>mainclass</mainClass>
<arguments>
</arguments>
</configuration>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>C:\....\parent.jar</systemPath>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
You can use a maven aggregator project pom for that.
Example:
<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.codehaus.mojo</groupId>
<artifactId>my-parent</artifactId>
<version>2.0</version>
<packaging>pom</packaging>
<modules>
<module>proj1</module>
<module>proj2</module>
</modules>
</project>
This way proj1 will always run before proj2.
I think is this what you want.
See https://maven.apache.org/pom.html#Aggregation for more information.
I have the next project structure:
app
module1
module2
...
moduleN
parent-pom
Project app contains only properties files and JasperReports's reports templates. Pom.xml of app:
<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>my-group</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0.0</version>
<relativePath>../parent-pom</relativePath>
</parent>
<artifactId>app</artifactId>
<version>${app-version}</version>
<packaging>pom</packaging>
<modules>
<module>../module1</module>
<module>../module2</module>
...
<module>../moduleN</module>
</modules>
I want to add jasperreports-maven-plugin for project app. I've tried next code (before <modules> section), but it doesn't work (self build wasn't called):
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<configuration>
<sourceDirectory>${basedir}/config/templates</sourceDirectory>
<outputDirectory>${basedir}/config/templates</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Is it possible to add self build to pom with modules?
The app project packaging is set to pom - so it can't have any other artifacts. You will need to move the jasper reports to one of the other modules or a separate module.