我过去已经迁移到 Tomcat 7[7.0.4.1] 启动需要 5 到 7 秒现在需要 30
我在 web.xml 中设置的其他帖子 metadata-complete="true"中设置的秒数解决了这个问题,但在我的情况下似乎没有解决我在 中添加了
和 metadata-complete="true"
>WEB-INF/web.xmltomcat/conf/web.xml
似乎都不起作用。
这里是tomcat/conf/web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="true"
version="3.0">
这里是WEB-INF/web.xml
的代码
<web-app metadata-complete="true" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
部署成功,这里是tomcat正在打印的trace。
INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
jul 22, 2013 4:33:08 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
这句话用了 30 多秒..
INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
我的问题是:
我哪里做错了??
我怎么能看到元数据是否完整设置为真?我该如何调用这个方法??
我们在项目中使用了[Spring,Hibernate,ZK]。
最佳答案
metadata-complete 也没有解决我的启动时间问题。问题是 tomcat 在启动时会扫描多个(几乎所有 jar)以查找注释和 tld 文件。当然,并非所有 jar 都包含 tld 文件和注释。为了改善您的启动时间,您可以排除这些 jar 。像下面这样的东西应该可以解决问题: 调整 conf/catalina.properties:
org.apache.catalina.startup.ContextConfig.jarsToSkip=*.jar
# Additional JARs (over and above the default JARs listed above) to skip when
# scanning for TLDs. The list must be a comma separated list of JAR file names.
# The following list will make sure stuff like jstl and spring-webmvc.jar etc which contain tld files are included
org.apache.catalina.startup.TldConfig.jarsToSkip=a*.jar,b*.jar,c*.jar,d*.jar,e*.jar,f*.jar,g*.jar,h*.jar,i*.jar,jc*.jar, jd*.jar, je*.jar, jl*.jar, jo*.jar, JO*.jar, jr*.jar, jso*.jar, jsr*.jar, jts*.jar,k*.jar,l*.jar,m*.jar,n*.jar,o*.jar,p*.jar,q*.jar,r*.jar,spring-a*.jar, spring-c*.jar, spring-e*.jar, spring-j*.jar, spring-s*.jar, spring-test*.jar, stax*.jar, st*.jar, t*.jar,u*.jar,v*.jar,w*.jar,x*.jar,y*.jar,z*.jar
关于java - Tomcat 7 慢启动元数据完整 ="true"web.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17656398/