I am trying to compile a Maven project named web-server which is dependent on search-client within the specified dependency version range [2.0,3.0). The compile fails however due to a "No versions available for > com.test.search:search-client:jar:[2.0,3.0) within specified range" in the repository.
These are the steps I am following:
Make my changes and build search-client locally
This builds a 2.0-SNAPSHOT jar for this client pom in my local m2 repository.
Try to build web-server which is dependent on the above
This does not compile giving the following error:
[ERROR] Failed to execute goal on project common: Could not resolve
dependencies for project com.test.web:common:jar:2.0-SNAPSHOT: Failed
to collect dependencies at
com.test.search:search-client:jar:[2.0,3.0): No versions available for
com.test.search:search-client:jar:[2.0,3.0) within specified range ->
[Help 1]
Web Server 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>
<parent>
<artifactId>web-parent</artifactId>
<groupId>com.test.web</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<properties>
<kotlin.version>1.3.61</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-client</artifactId>
<version>[2.0,3.0)</version>
</dependency>
.
.
.
//Many More Dependencies
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<!--<testSourceDirectory>src/test/kotlin</testSourceDirectory>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
search-client 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">
<parent>
<artifactId>search-parent</artifactId>
<groupId>com.test.search</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>search-client</artifactId>
<packaging>jar</packaging>
<name>test Search Client</name>
<dependencies>
<!-- test Search -->
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!-- test -->
<dependency>
<groupId>com.test.common</groupId>
<artifactId>common-client</artifactId>
</dependency>
<!-- Languages & Frameworks -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<!-- Utils -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Codecs -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Does 2.0-SNAPSHOT not lie in [2.0,3.0)? I have been strictly asked not to increase the version. Also, how can I go about local development in such maven dependency design?
Please help, I am stuck!
Many thanks in advance :)
According to POM Reference, Version Order Specification:
"1-snapshot" < "1" < "1-sp" (qualifier padding)
2.0-SNAPSHOT is less than 2.0, which always was in Maven: snapshot versions are the pre-versions of the next release version.
So, no, 2.0-SNAPSHOT does not lie in [2.0,3.0) (2.0 <= x < 3.0). (1,3.0) (1 < x < 3.0) should do it.
And, there's a typo in your Web Server POM:
<version>_____3,0)</version>
Related
I am trying to compile groovy code with java 11 and getting the below error:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xml: Compilation failure
Found 0 errors and 0 warnings
The same is working fine with java 8.
Any help on this would be appreciated.
This is the POM file being used.
I have updated the pom file with latest groovy versions i.e., 3.0.7 and the maven compiler version is 3.8.1
<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>
<groupId>com.comcast.ted</groupId>
<artifactId>TED</artifactId>
<version>5.0-SNAPSHOT</version>
</parent>
<artifactId>xml</artifactId>
<name>xml</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.7</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am having a situation where two jars of different versions of apache-commons-lang3 are being packaged in my application WAR even when a single version v3.4 is mentioned in my dependencyManagement.
link.
I explored a little and figured out the wrong jar i.e., v3.1 is coming from maven surefire plugin.
Now, I want to exclude apache-commons-lang3 jar that is coming from maven surefire plugin. However, I tried many ways to force surefire to take the latest jar and bring in v3.4 but I am not able to do so.
Does there exist a way to do the above? That is, exclude a transient jar coming from a maven plugin?
I am trying to build this pom but still it is downloading v3.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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bhatinik</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<apache.commons.lang3.version>3.4</apache.commons.lang3.version>
<maven.surefire.plugin.version>2.19.1</maven.surefire.plugin.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.lang3.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.lang3.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>${module.test.excludes}</exclude>
<excludeArtifactIds>commons-lang3</excludeArtifactIds>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency> </dependencies>
</project>
I was trying to create a maven project and add spring boot dependencies later, but i kept getting error highlights on maven plugins. Here below is the screenshot:
Maven Projects screenshot from intellij
And my POM file contents:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>org.springframework</groupId>
<artifactId>gs-producing-web-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>java.net</id>
<url>http://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<dependencies>
<!-- tag::springws[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<!-- end::springws[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::xsd[] -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<!-- end::xsd[] -->
</plugins>
</build>
May be you have just added the dependencies in your pom.xml file but they are not in your local maven repository. For this purpose you have build/rebuild the project. Once you successfully build the project those dependencies will add to your local repository and will not show these error.
Have you built successfully already? If still there are errors, then might be other issue.
I quite stuck with something I think is basic, but Maven does not enable me to package my project twice without doing some cleaning.
I'm working on a java project with multi-dependencies (different modules developped by different people, usual stuff) and one of them uses java classes generated using JAXB.
I'm using maven to make all that work together (one pom per module and one pom parent to built the whole project, basic stuff I said).
When I package the modules using dedicated pom there is no trouble (even if I do several successive package without cleaning). When I package the whole project for the first time (or after a clean) there is no problem at all too (*.java generated from XSDs, *.class, tests executed, Jar generated properly).
But now, if I re-do the package command, then maven says that it cannot find the classes generated using JAXB (and, then there are compilation issues in other java classes due to symbols that cannot be found, logic).
I think that Maven kind of "forgot" that it generated java classes during previous package but I don't know how to make it remember. So, up to now, I'm obliged to make it generate those classes and delete them, again and again (and its quite long as the clean cleans every other modules that will then be built again...).
So, if anyone has any clue on what I'm missing/doing wrong, I would be glad as none of my search here and there were successful.
I hope that I was clear enough. If not, feel free to ask for further explanation.
Thank you
P.S. I forgot to tell you that I'm using Maven with command line
EDIT :
Parent 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>my.package.for.mysoft</groupId>
<artifactId>mysoft-parent</artifactId>
<packaging>pom</packaging>
<version>1.3.0-SNAPSHOT</version>
<name>Main parent for MySoft modules</name>
<properties>
<mysoft_version>1.3.0-SNAPSHOT</mysoft_version>
<main_other_soft_version>1.3.1</main_other_soft_version>
<!-- SCADAsoft packages -->
<scadasoft.version>6.2.4.4</scadasoft.version>
<!-- Hypervisor packages -->
<othersoft2.version>2.9.0_P03</othersoft2.version>
<othersoft1.version>1.8.0_P03</othersoft1.version>
<othersoft3.version>1.2.8</othersoft3.version>
<hv.quartz-tc.version>2.2.1</hv.quartz-tc.version>
<!-- TVS packages -->
<tvs.common.version>3.6.5.0001</tvs.common.version>
<!-- Loggers -->
<slf4j.version>1.7.2</slf4j.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<modules>
<module>mysoft-bom</module>
<module>mysoft-jaxb</module>
<module>mysoft-common</module>
<module>My-project-that-uses-jaxb-generated-classes</module>
</modules>
<distributionManagement>
<snapshotRepository>
<id>soft-repo-releases</id>
<name>SOFT maven repository - SNAPSHOTS</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_snapshots/</url>
</snapshotRepository>
<repository>
<id>soft-repo-releases</id>
<name>Soft maven repository - RELEASES</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_releases/</url>
</repository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.terracotta.quartz</groupId>
<artifactId>quartz-terracotta</artifactId>
<version>${hv.quartz-tc.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<deployAtEnd>false</deployAtEnd>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-parent-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>project.parent.version</property>
<regex>1.3.0.SNAPSHOT</regex>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Pom of the module that generates java classes
<?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>mysoft-jaxb</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>my.package.for.mysoft</groupId>
<artifactId>mysoft-parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>MySoft generated classes</name>
<description>Classes generated by JAXB</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<othersoft1.version>1.8.0</othersoft1.version>
<othersoft2.version>2.9.0</othersoft2.version>
<othersoft3.version>1.2.8</othersoft3.version>
<mysoft.data.model>${main_other_soft_version}</mysoft.data.model>
<mysoft.common>${main_other_soft_version}</mysoft.common>
<mysoft.core>${main_other_soft_version}</mysoft.core>
<skipTests>false</skipTests>
</properties>
<distributionManagement>
<snapshotRepository>
<id>soft-repo-releases</id>
<name>Soft maven repository - SNAPSHOTS</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_snapshots/</url>
</snapshotRepository>
<repository>
<id>soft-repo-releases</id>
<name>Soft maven repository - RELEASES</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_releases/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<environmentVariables>
<PATH>${java.library.path};${my_api_dir}\Bin;${project.basedir}\..\module-with-cpp\target\nar\lib\x86-Windows-msvc\jni</PATH>
</environmentVariables>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
<!-- Maven Compiler plugin: Inherited from Parent -->
<!-- Maven Jar plugin: Inherited from Parent -->
<!-- Maven Check Style Plugin: Inherited from Parent -->
<!-- Maven Assembly Plugin Plugin: Inherited from Parent -->
<!-- Maven JavaDoc Plugin: Inherited from Parent -->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
</plugin>
<!-- generation of java classes using JAXB -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.build.sourceDirectory}/../resources/xsd/config.xsd</source>
</sources>
</configuration>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>system_configuration/**</exclude>
<exclude>mysoft.properties</exclude>
<exclude>connector_configuration.xml</exclude>
<exclude>log4j.xml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Module that uses the one with JAXB generated java classes
<?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>My-project-that-uses-jaxb-generated-classes</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>my.package.for.mysoft</groupId>
<artifactId>mysoft-parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>My project module 1</name>
<description>Module that uses Jaxb generated classes</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<othersoft1.version>1.8.0</othersoft1.version>
<othersoft2.version>2.9.0</othersoft2.version>
<othersoft3.version>1.2.8</othersoft3.version>
<mysoft.data.model>${main_other_soft_version}</mysoft.data.model>
<mysoft.common>${main_other_soft_version}</mysoft.common>
<mysoft.core>${main_other_soft_version}</mysoft.core>
<skipTests>false</skipTests>
</properties>
<distributionManagement>
<snapshotRepository>
<id>soft-repo-releases</id>
<name>Soft maven repository - SNAPSHOTS</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_snapshots/</url>
</snapshotRepository>
<repository>
<id>soft-repo-releases</id>
<name>Soft maven repository - RELEASES</name>
<url>http://url.of.the.server:123/nexus/content/repositories/mysoft_releases/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dependency.package.1</groupId>
<artifactId>connector-sdk-impl</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- datamodels -->
<dependency>
<groupId>dependency.package.1</groupId>
<artifactId>data-model-1</artifactId>
<version>3.6.5.0001</version>
</dependency>
<dependency>
<groupId>dependency.package.2</groupId>
<artifactId>data-model-2</artifactId>
<version>${scadasoft.version}</version>
</dependency>
<!--
...
-->
<dependency>
<groupId>my.package.for.mysoft</groupId>
<artifactId>mysoft-common</artifactId>
<version>${mysoft_version}</version>
</dependency>
<dependency>
<groupId>my.package.for.mysoft</groupId>
<artifactId>mysoft-jaxb</artifactId>
<version>${mysoft_version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<environmentVariables>
<PATH>${java.library.path};${my_api_dir}\Bin;${project.basedir}\..\module-with-cpp\target\nar\lib\x86-Windows-msvc\jni</PATH>
</environmentVariables>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
<!-- Maven Compiler plugin: Inherited from Parent -->
<!-- Maven Jar plugin: Inherited from Parent -->
<!-- Maven Check Style Plugin: Inherited from Parent -->
<!-- Maven Assembly Plugin Plugin: Inherited from Parent -->
<!-- Maven JavaDoc Plugin: Inherited from Parent -->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
</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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>system_configuration/**</exclude>
<exclude>mysoft.properties</exclude>
<exclude>connector_configuration.xml</exclude>
<exclude>log4j.xml</exclude>
</excludes>
</configuration>
</plugin>
<!-- One of the dependencies uses C++ -->
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>nar-download</id>
<goals>
<goal>nar-download</goal>
</goals>
</execution>
<execution>
<id>nar-test-unpack</id>
<goals>
<goal>nar-test-unpack</goal>
</goals>
</execution>
<execution>
<id>nar-integration-test</id>
<goals>
<goal>nar-integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I would like use spring and maven for a webservice and when i start the application i have this problem:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
(default-cli) on project WebService: Command execution failed. Process
exited with an error: 1 (Exit value: 1) -> [Help 1]
my 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>fr.itevents</groupId>
<artifactId>WebService</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>WebService</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Can you help me?
You are using Spring Boot and are trying very hard not to use it, at least in your pom.xml. First you don't need the javaee-web-api dependency. The idea of the starters is that those manage all needed dependencies. So simply remove it. The same applies to the spring-boot-starter as that already is implied by the spring-boot-starter-web dependency.
You have defined a lot of additional plugins for which Spring Boot already has the needed configuration, which you are now overriding or even worse using a very old version. Remove all the plugins and leave only the Spring Boot one.
So what you basically need to do is simply strip your pom.xml which should leave you with something like the following.
<?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>fr.itevents</groupId>
<artifactId>WebService</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>WebService</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.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.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Pro Tip: I would suggest using a jar instead of a war that way you can simply deliver a jar file and do java -jar WebService.jar and have everything up and running in no time. You don't really need a war for that anymore.