2016-12-06 3 views
0

Mon professeur veut que j'exécute javaee7 sdk sample "annotation-war". Ensuite, je télécharge le javaee7 sdk de http://www.oracle.com/technetwork/java/javaee/downloads/index.html. Mais, je ne sais pas comment le faire fonctionner.Comment lancer des échantillons javaee7 sdk?

J'ai essayé les étapes suivantes:

D'abord, j'importer du code dans Intelij IDEA, et exécuter mvn cargo:run, mais 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 

Je pense peut-être que je l'ai fait la mauvaise chose, donc J'ai lu le docs dans "annotation-war". Vous pouvez exécuter mvn clean et mvn verify. Mais quand je lance mvn cargo:run -Dglassfish.home=C:\zjf\soft\glassfish, je rencontre toujours le même problème:

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 

Je ne sais vraiment pas comment exécuter des échantillons SDK JavaEE. Est-ce que quelqu'un qui sait comment l'utiliser peut m'aider?

Répondre

0

Le moyen le plus simple de l'exécuter est de commencer par construire le projet avec mvn install qui produira un fichier WAR. Le bas du journal vous indiquera le chemin complet et absolu du fichier WAR. l'objectif Maven install va également le copier dans votre dépôt local qui est géré par Maven, ainsi vous verrez deux chemins différents vers le même fichier WAR. Chacune de ces œuvres, par exemple:

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

Vous pouvez ensuite utiliser l'outil asadmin dans GlassFish pour déployer le fichier WAR, tout d'abord en vous assurant GlassFish est en cours d'exécution:

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 

Ce n'est pas la seule façon pour le faire fonctionner (il y en a beaucoup) mais vous pouvez trouver que c'est le plus facile à vivre, avec le moins de choses qui pourraient mal tourner, malgré le fait qu'il soit un peu long.

+0

Merci beaucoup. Je devrais lire les étapes suivantes. – hellozjf

+0

Oui, je m'attends à ce que vous vous y habituiez finalement, alors les instructions supplémentaires devraient être plus claires et plus utiles. – Mike