标签:
执行以下命令报错:
mvn archetype:create -DgroupId=org.infohold.stormexample -DpackageName=org.infohold.stormexample -DartifactId=simple
错误信息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of mojo org.apache.maven.plugins:maven-archetype-plugin:2.4:create for parameter #: Cannot create instance of interface org.apache.maven.artifact.repository.ArtifactRepository: org.apache.maven.artifact.repository.ArtifactRepository.() -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
报错原因:
maven3中create命令已过时,使用generate命令代替。
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook
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>org.sonatype.mavenbook.ch03</groupId> <artifactId>simple</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>simple</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>org.sonatype.mavenbook.ch03.App</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
编译: mvn package
编译后生成target目录
执行实例: java -cp target/simple-1.0-SNAPSHOT.jar org.sonatype.mavenbook.ch03.App 或 java -jar target/simple-1.0-SNAPSHOT.jar
标签:
原文地址:http://www.cnblogs.com/labing/p/5233320.html