Comment faire pour exécuter Tomcat 7 en utilisant le plugin Tomcat Maven 2?
-
22-10-2019 - |
Question
J'utilise Maven 2 et j'ai un externe Tomcat 7 . Je me demandais comment exécuter Tomcat 7 d'utiliser le plugin Maven Tomcat.
Et ne plugin Maven Tomcat Maven 3 exécute le Tomcat 7 par défaut.
Merci.
La solution
Cela fonctionne pour moi: http://tomcat.apache.org/maven-plugin- 2.1 /
Avec ce plugin config:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
Et en cours d'exécution avec
mvn clean install tomcat7:run
(S'il vous plaît noter que tomcat7:run
, pas tomcat:run
.)
Documentation Plugin est ici: http: / /tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/plugin-info.html
Par exemple, la valeur par défaut de additionalConfigFilesDir
est ${basedir}/src/main/tomcatconf
, donc si vous mettez vos configs dans ce répertoire, il sera utilisé sur tomcat7:run
.
mvn -X tomcat7:run
imprime le configration, par exemple:
[DEBUG] (f) additionalConfigFilesDir = /workspace/webtest1/src/main/tomcatconf
[DEBUG] (f) configurationDir = /workspace/webtest1/target/tomcat
...
[DEBUG] (f) path = /webtest1
...
[DEBUG] (f) port = 8080
[DEBUG] (f) project = ...:webtest1:0.0.1-SNAPSHOT @ /workspace/webtest1/pom.xml
...
[DEBUG] (f) warSourceDirectory = /workspace/webtest1/src/main/webapp
Notez que les points de warSourceDirectory
à src
(non target
), il fonctionne comme un projet Web dynamique habituelle, vous pourriez changer vos pages JSP, HTMLs et il sera visible immédiatement. Voilà pourquoi le dossier target/tomcat/webapps
est vide.
Autres conseils
Avez-vous essayé tomcat plug-in 7 ?