![](/img/trans.png)
[英]Maven tomcat plugin: tomcat7:run or tomcat7:run-war?
[英]Tomcat7 + Maven plugin: Tomcat will not start with my war
我正在使用java 8
和tomcat 7
和maven 3.3.9
與maven tomcat插件:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8085</port>
</configuration>
</plugin>
</plugins>
</build>
有一段時間一切正常, tomcat7:run-war
工作。
現在我沒有明顯的理由得到這個錯誤:
[INFO] --- tomcat7-maven-plugin:2.2:run-war (default-cli) @ tomcat-example ---
[INFO] Running war on http://localhost:8085/tomcat-example
[INFO] Using existing Tomcat server configuration at /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat
[INFO] create webapp with contextPath: /tomcat-example
Jul 04, 2016 2:30:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8085"]
Jul 04, 2016 2:30:45 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Jul 04, 2016 2:30:45 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.693s
[INFO] Finished at: Mon Jul 04 14:30:45 IDT 2016
[INFO] Final Memory: 17M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run-war (default-cli) on project tomcat-example: Could not start Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: Failed to start component [Realm[MemoryRealm]]: Memory database file /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/tomcat-users.xml cannot be read -> [Help 1]
這是錯誤:
Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: Failed to start component [Realm[MemoryRealm]]: Memory database file /Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/tomcat-users.xml cannot be read -> [Help 1]
誰負責在我的目標目錄中編寫tomcat配置,為什么不寫?
執行mvn clean
以清理目標目錄。
然后再試一次,tomcat-maven-plugin將重新創建tomcat文件夾(包括文件tomcat-users.xml
)。
只需從應用程序中刪除目標文件夾,然后再次運行您的應用。 這個對我有用。
您可以嘗試在以下位置為tomcat用戶創建文件:
/Users/shikloshi/java_workspace/webapp-examples/tomcat-example/target/tomcat/conf/
然后將其添加到其中:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="tomcat,admin,manager"/>
</tomcat-users>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.