2016-12-06 73 views
0

我的老师想让我运行javaee7 sdk示例“annotation-war”。然后我从http://www.oracle.com/technetwork/java/javaee/downloads/index.html下载javaee7 sdk。但是,我不知道如何运行它。如何运行javaee7 sdk示例?

我曾尝试以下步骤:

首先,我输入代码到Intelij IDEA,并运行mvn cargo:run,但some error happen

"C:\Program Files\Java\jdk1.8.0_101\bin\java" -Dmaven.multiModuleProjectDirectory=C:\zjf\code\IDEA\javaee_samples\servlet\annotation-war -Dmaven.home=C:\zjf\soft\apache-maven-3.3.9 -Dclassworlds.conf=C:\zjf\soft\apache-maven-3.3.9\bin\m2.conf -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\zjf\soft\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.3 -s C:\zjf\soft\apache-maven-3.3.9\conf\settings.xml -Dmaven.repo.local=C:\zjf\soft\apache-maven-3.3.9\repo org.codehaus.cargo:cargo-maven2-plugin:1.4.0:run 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building annotation-war 4.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- cargo-maven2-plugin:1.4.0:run (default-cli) @ annotation-war --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.422 s 
[INFO] Finished at: 2016-12-06T19:12:34+08:00 
[INFO] Final Memory: 8M/184M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:run (default-cli) on project annotation-war: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:run failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [glassfish4x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [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. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

Process finished with exit code 1 

那么我想可能是我做了错误的事情,所以我在“注释战争”中读到了docs。可以运行mvn cleanmvn verify。但是,当我运行mvn cargo:run -Dglassfish.home=C:\zjf\soft\glassfish,我仍然遇到了同样的问题:

C:\zjf\code\IDEA\javaee_samples\servlet\annotation-war>mvn cargo:run -Dglassfish.home=C:\zjf\soft\glassfish 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building annotation-war 4.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- cargo-maven2-plugin:1.4.0:run (default-cli) @ annotation-war --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.038 s 
[INFO] Finished at: 2016-12-06T20:59:57+08:00 
[INFO] Final Memory: 8M/184M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:run (default-cli) on project annotation-war: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:run failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [glassfish4x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [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. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

我真的不知道该怎么办好的JavaEE SDK样本。任何知道如何运行的人都可以给我一些帮助吗?

回答

0

让它运行的最简单方法是首先用mvn install构建项目,它将输出一个WAR文件。日志底部会告诉你WAR文件的完整绝对路径。 Maven的目标也会把它拷贝到由Maven管理的本地仓库中,所以你会看到两个到同一个WAR文件的不同路径。无论这些作品,例如:

/path/to/my/app/target/annotation-war-1.0.0-SNAPSHOT.war 

然后可以使用GlassFish中asadmin工具部署WAR文件,首先确保GlassFish的运行:

C:\zjf\soft\glassfish\glassfish4\bin\asadmin start-domain 
C:\zjf\soft\glassfish\glassfish4\bin\asadmin deploy /path/to/my/app/target/annotation-war-1.0.0-SNAPSHOT.war 

这是不是唯一的方法让它运行(有很多),但是你可能会发现这是最容易被忽略的,尽管它有点冗长,但最少的东西可能会出错。

+0

非常感谢。我应该阅读以下步骤。 – hellozjf

+0

是的,我希望你最终会习惯它,然后额外的指示应该更清晰,更有帮助。 – Mike