【Java】tomcat启动不加载spring相关
IDEA里Spring mvc启动不加载spring相关文件,直接启动成功,访问404.
server控制台日志如下:
E:\apache-tomcat-8.5.24\bin\catalina.bat run[2018-01-02 09:59:52,498] Artifact personalWebsite:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\xiati\.IntelliJIdea2017.2\system\tomcat\Unnamed_personalWebsite_4"
Using CATALINA_HOME: "E:\apache-tomcat-8.5.24"
Using CATALINA_TMPDIR: "E:\apache-tomcat-8.5.24\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_80\jre"
Using CLASSPATH: "E:\apache-tomcat-8.5.24\bin\bootstrap.jar;E:\apache-tomcat-8.5.24\bin\tomcat-juli.jar"
02-Jan-2018 09:59:53.771 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.24
02-Jan-2018 09:59:53.775 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Nov 27 2017 13:05:30 UTC
02-Jan-2018 09:59:53.775 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.24.0
02-Jan-2018 09:59:53.775 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8.1
02-Jan-2018 09:59:53.775 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.3
02-Jan-2018 09:59:53.776 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
02-Jan-2018 09:59:53.776 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.7.0_80\jre
02-Jan-2018 09:59:53.776 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_80-b15
02-Jan-2018 09:59:53.776 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-Jan-2018 09:59:53.776 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\xiati\.IntelliJIdea2017.2\system\tomcat\Unnamed_personalWebsite_4
02-Jan-2018 09:59:53.777 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: E:\apache-tomcat-8.5.24
02-Jan-2018 09:59:53.777 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\xiati\.IntelliJIdea2017.2\system\tomcat\Unnamed_personalWebsite_4\conf\logging.properties
02-Jan-2018 09:59:53.779 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Jan-2018 09:59:53.779 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
02-Jan-2018 09:59:53.779 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1089
02-Jan-2018 09:59:53.780 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
02-Jan-2018 09:59:53.780 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\xiati\.IntelliJIdea2017.2\system\tomcat\Unnamed_personalWebsite_4
02-Jan-2018 09:59:53.781 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=E:\apache-tomcat-8.5.24
02-Jan-2018 09:59:53.782 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=E:\apache-tomcat-8.5.24\temp
02-Jan-2018 09:59:53.782 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.7.0_80\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_80\bin;C:\Program Files\Java\jdk1.7.0_80\jre\bin;E:\Android\sdk\platform-tools;E:\Android\sdk\tools;C:\Program Files\apache-maven-3.3.9\bin;C:\Program Files\TortoiseSVN\bin;E:\php-5.6.30;E:\Git\cmd;E:\phantomjs-2.1.1-windows\bin;E:\wamp64\bin\php\php5.6.25\ext;E:\wamp64\bin\php\php5.6.25;E:\wamp64\bin\php;E:\nodejs\;C:\Users\xiati\AppData\Local\Programs\Python\Python35\Scripts\;C:\Users\xiati\AppData\Local\Programs\Python\Python35\;C:\Users\xiati\AppData\Local\Microsoft\WindowsApps;C:\Users\xiati\AppData\Roaming\npm;;.]
02-Jan-2018 09:59:53.946 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
02-Jan-2018 09:59:53.973 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Jan-2018 09:59:54.005 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
02-Jan-2018 09:59:54.012 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Jan-2018 09:59:54.013 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 860 ms
02-Jan-2018 09:59:54.095 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
02-Jan-2018 09:59:54.095 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.24
02-Jan-2018 09:59:54.111 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Jan-2018 09:59:54.127 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
02-Jan-2018 09:59:54.131 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 117 ms
Connected to server
[2018-01-02 09:59:54,586] Artifact personalWebsite:war exploded: Artifact is being deployed, please wait...
02-Jan-2018 09:59:59.937 信息 [RMI TCP Connection(5)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2018-01-02 10:00:00,086] Artifact personalWebsite:war exploded: Artifact is deployed successfully
[2018-01-02 10:00:00,086] Artifact personalWebsite:war exploded: Deploy took 5,500 milliseconds
02-Jan-2018 10:00:01.405 信息 [http-nio-8080-exec-3] org.apache.tomcat.util.http.parser.Cookie.logInvalidHeader A cookie header was received [1513734010; Webstorm-5bd75042=039276b2-b16d-44e1-98d5-140a979b4508; JSESSIONID=EBBA64808168BB7D90D7A85A023983EE] that contained an invalid cookie. That cookie will be ignored.Note: further occurrences of this error will be logged at DEBUG level.
02-Jan-2018 10:00:04.113 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\apache-tomcat-8.5.24\webapps\manager]
02-Jan-2018 10:00:04.273 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\apache-tomcat-8.5.24\webapps\manager] has finished in [159] ms
在Tomcat localhost Log日志下有如下输出:
02-Jan-2018 10:00:00.007 信息 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
web.xml相关配置如下:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>personalWebsite</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-mvc-*.xml
</param-value>
</context-param>
<servlet>
<servlet-name>springMvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc-web.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- The 1nd filter, for encoding -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<session-config>
<session-timeout>720</session-timeout>
</session-config>
</web-app>
tomcat启动后再Target目录生成文件如下:
是在费解问题出在哪里,麻烦大牛帮我看看问题所在 。
回答
已解决,pom.xml打包排除了web.xml,导致无法加载。
<build> <finalName>personalWebsite-v1.0.0</finalName>
<!--<plugins>-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-war-plugin</artifactId>-->
<!--<version>2.1.1</version>-->
<!--<configuration>-->
<!--<packagingExcludes>WEB-INF/web.xml</packagingExcludes>-->
<!--</configuration>-->
<!--</plugin>-->
<!--</plugins>-->
</build>
以上是 【Java】tomcat启动不加载spring相关 的全部内容, 来源链接: utcz.com/a/91495.html