java - Spring boot and maven exec plugin issue -
i've created bare-bone maven project, empty except pom.xml
.
with pom (note parent
element commented-out):
<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>springboot-test</groupid> <artifactid>springboot-test</artifactid> <version>1.0.0-snapshot</version> <!-- <parent> --> <!-- <groupid>org.springframework.boot</groupid> --> <!-- <artifactid>spring-boot-starter-parent</artifactid> --> <!-- <version>1.1.9.release</version> --> <!-- </parent> --> <build> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project>
sample run:
$ mvn exec:java -dexec.mainclass=test [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building springboot-test 1.0.0-snapshot [info] ------------------------------------------------------------------------ [info] [info] --- exec-maven-plugin:1.3.2:java (default-cli) @ springboot-test --- [warning] warning: killafter deprecated. need ? please comment on mexec-6. [warning] java.lang.classnotfoundexception: test @ java.net.urlclassloader$1.run(urlclassloader.java:372) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:360) @ java.lang.classloader.loadclass(classloader.java:424) @ java.lang.classloader.loadclass(classloader.java:357) @ org.codehaus.mojo.exec.execjavamojo$1.run(execjavamojo.java:281) @ java.lang.thread.run(thread.java:745) [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 0.480 s [info] finished at: 2014-12-05t13:45:34-05:00 [info] final memory: 8m/176m [info] ------------------------------------------------------------------------ [error] failed execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project springboot-test: exception occured while executing java class. test -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojoexecutionexception
this expected (there's no clas test
in project).
using pom (i.e. un-commenting parent
):
<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>springboot-test</groupid> <artifactid>springboot-test</artifactid> <version>1.0.0-snapshot</version> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.1.9.release</version> </parent> <build> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project>
sample run:
$ mvn exec:java -dexec.mainclass=test [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building springboot-test 1.0.0-snapshot [info] ------------------------------------------------------------------------ [info] [info] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ springboot-test >>> [info] [info] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ springboot-test <<< [info] [info] --- exec-maven-plugin:1.2.1:java (default-cli) @ springboot-test --- [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 0.550 s [info] finished at: 2014-12-05t13:45:27-05:00 [info] final memory: 12m/178m [info] ------------------------------------------------------------------------ [error] failed execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project springboot-test: parameters 'mainclass' goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java missing or invalid -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/pluginparameterexception
same thing happens exec-maven-plugin:1.3.2:
$ mvn org.codehaus.mojo:exec-maven-plugin:1.3.2:java -dexec.mainclass=test [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building springboot-test 1.0.0-snapshot [info] ------------------------------------------------------------------------ [info] [info] --- exec-maven-plugin:1.3.2:java (default-cli) @ springboot-test --- [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 0.400 s [info] finished at: 2014-12-05t13:52:46-05:00 [info] final memory: 6m/157m [info] ------------------------------------------------------------------------ [error] failed execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project springboot-test: parameters 'mainclass' goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java missing or invalid -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/pluginparameterexception
additional information:
$ java -version java version "1.8.0_11" java(tm) se runtime environment (build 1.8.0_11-b12) java hotspot(tm) 64-bit server vm (build 25.11-b03, mixed mode) $ mvn -v apache maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17t09:51:42-04:00) maven home: c:\dev\bin\apache-maven-3.2.2 java version: 1.8.0_11, vendor: oracle corporation java home: c:\progra~1\java\jdk1.8.0_11\jre default locale: en_us, platform encoding: cp1252 os name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
questions:
- why failing / how fix?
- why failing when
parent
added? howexec-maven-plugin
influenced this?
(as side note, love fact windows 7 belongs faimly: "dos", i'm waiting family: "cp/m" implemented windows 8.1)
its because spring-boot adding maven configuration project. if using eclipse, there's tab called: 'effective pom'.
from tab can see adds snippet below:
<plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <version>1.2.1</version> <configuration> <mainclass>${start-class}</mainclass> </configuration> </plugin>
so when run spring-boot parent, looks value of ${start-class}
, resolves empty unless defined it, that's when see error not having value mainclass
parameter.
add project:
<properties> <start-class>com.test</start-class> </properties>
then run it: clean compile exec:java
[info] --- exec-maven-plugin:1.2.1:java (default-cli) @ springboot-test --- **********test************** [info] ------------------------------------------------------------------------ [info] build success [info] ------------------------------------------------------------------------ [info] total time: 2.388 s [info] finished at: 2014-12-05t15:25:05-06:00 [info] final memory: 17m/231m [info] ------------------------------------------------------------------------
you can provide value start-class
property on command line, works if didn't define inside pom file:
mvn exec:java -dstart-class=com.test
Comments
Post a Comment