java - Tomcat 7 慢启动元数据完整 ="true"web.xml

标签 java metadata tomcat7 web.xml

我过去已经迁移到 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/

相关文章:

java - 如何在同一个java webapp上使用不同的子域

java - 从jsp的post数据中获取Null

Java : Retrieve Column names from ResultSet

c# - ApiMember 属性未显示在 ServiceStack 生成的元数据中

Tomcat ExpiresFilter 无法正常工作

java - 在 Ubuntu 14.04 LTS 上的 Tomcat 7 中找不到 MySQL JDBC 驱动程序

java - 主键约束违规 : Hibenate Save Method Not updating but trying to insert new row with same primary key

java - 在Dropwizard的数据库迁移包装器中,是否可以基于上下文进行迁移?

java - 将斯坦福情绪分析与 java 集成时出现错误

windows - 将元数据从一个文件批量复制到另一个文件 (EXIFTOOL)