Spring mvc annotation配置。升级到弹簧4.3.9时出错404
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring mvc annotation配置。升级到弹簧4.3.9时出错404相关的知识,希望对你有一定的参考价值。
我的java spring mvc项目是在4.0.6.RELEASE spring version Project加载http://localhost:8080/的主页。当我在pom.xml中更改为更新的4.3.9.RELEASE时,我得到错误404 tomcat页面。
我使用tomcat Apache Tomcat / 9.0.0.M22,IntelliJ,windows10,chrome(但是edge也显示了404)。我试图重建项目,刷新maven,但它没有用。
我附加了配置文件和文件夹结构。我希望代码不是太多。谢谢你的帮助。
AppConfig中
/** imports */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.websystique.springmvc")
public class AppConfig
@Bean
public ViewResolver viewResolver()
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
@Bean
public MessageSource messageSource()
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
AppController的
/** imports */
@Controller
@RequestMapping("/")
public class AppController
@Autowired
QuestionService service;
@Autowired
MessageSource messageSource;
@Autowired
PointsCounter pointsCounter;
private List<Answer> answerList;
/**
* Load home page
*/
@RequestMapping(value = "/")
public String mainPage(ModelMap modelMap)
return "home";
/** More methods (...)
pom.hml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>websystique</groupId>
<artifactId>websystique</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<springframework.version>4.3.9.RELEASE</springframework.version>
<hibernate.version>4.3.6.Final</hibernate.version>
<mysql.connector.version>5.1.31</mysql.connector.version>
<joda-time.version>2.3</joda-time.version>
<testng.version>6.9.4</testng.version>
<mockito.version>1.10.19</mockito.version>
<h2.version>1.4.187</h2.version>
<dbunit.version>2.2</dbunit.version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>$springframework.version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>$springframework.version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>$springframework.version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>$springframework.version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>$springframework.version</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>$hibernate.version</version>
</dependency>
<!-- jsr303 validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>$mysql.connector.version</version>
</dependency>
<!-- Joda-Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>$joda-time.version</version>
</dependency>
<!-- To map JodaTime with database type -->
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.0.0.CR1</version>
</dependency>
<!-- Servlet+JSP+JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Testing dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>$springframework.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>$testng.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>$mockito.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>$h2.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>$dbunit.version</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>SpringHibernateExample</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>SpringHibernateExample</finalName>
</build>
编辑---------我的服务器日志(IntelliJ) - Spring 4.3.9 - 错误404
"C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\catalina.bat"
run
[2017-08-16 01:30:24,219] Artifact questions-websystique:war exploded:
Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_121"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat
9.0\bin\tomcat-juli.jar"
16-Aug-2017 01:30:24.867 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M22
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 21 2017 09:44:18 UTC
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_121\jre
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
16-Aug-2017 01:30:24.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20\conf\logging.properties
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
16-Aug-2017 01:30:24.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
16-Aug-2017 01:30:24.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20
16-Aug-2017 01:30:24.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
16-Aug-2017 01:30:24.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp
16-Aug-2017 01:30:24.870 INFO [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.8.0_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Java\jdk1.8.0_121\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Max\AppData\Local\Microsoft\WindowsApps;C:\sqlite-tools-win32-x86-3190200;;.]
16-Aug-2017 01:30:24.981 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
16-Aug-2017 01:30:24.995 INFO [main] org.apache.tomcat.util.net.NioselectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Aug-2017 01:30:24.998 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
16-Aug-2017 01:30:25.000 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Aug-2017 01:30:25.000 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 367 ms
16-Aug-2017 01:30:25.028 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
16-Aug-2017 01:30:25.028 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M22
16-Aug-2017 01:30:25.035 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
16-Aug-2017 01:30:25.041 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
16-Aug-2017 01:30:25.044 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 43 ms
Connected to server
[2017-08-16 01:30:25,320] Artifact questions-websystique:war exploded: Artifact is being deployed, please wait...
16-Aug-2017 01:30:27.073 INFO [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.
[2017-08-16 01:30:27,114] Artifact questions-websystique:war exploded: Artifact is deployed successfully
[2017-08-16 01:30:27,114] Artifact questions-websystique:war exploded: Deploy took 1 794 milliseconds
16-Aug-2017 01:30:35.036 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager]
16-Aug-2017 01:30:35.062 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager] has finished in [25] ms
Chrome显示了这一点:
HTTP Status 404 – Not Found
Type Status Report
Message /
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.0.M22
这是工作版本的日志 - 春季4.0.6.RELEASE
"C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\catalina.bat" run
[2017-08-16 07:29:01,446] Artifact questions-websystique:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_121"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\tomcat-juli.jar"
16-Aug-2017 19:29:01.908 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M22
16-Aug-2017 19:29:01.909 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 21 2017 09:44:18 UTC
16-Aug-2017 19:29:01.909 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
16-Aug-2017 19:29:01.909 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_121\jre
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20\conf\logging.properties
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
16-Aug-2017 19:29:01.910 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
16-Aug-2017 19:29:01.911 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
16-Aug-2017 19:29:01.911 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Max\.IntelliJIdea2017.2\system\tomcat\Unnamed_websystique_20
16-Aug-2017 19:29:01.911 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
16-Aug-2017 19:29:01.911 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp
16-Aug-2017 19:29:01.911 INFO [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.8.0_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Java\jdk1.8.0_121\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Max\AppData\Local\Microsoft\WindowsApps;C:\sqlite-tools-win32-x86-3190200;;.]
16-Aug-2017 19:29:01.980 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
16-Aug-2017 19:29:01.993 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Aug-2017 19:29:01.994 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
16-Aug-2017 19:29:01.996 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Aug-2017 19:29:01.996 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 256 ms
16-Aug-2017 19:29:02.016 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
16-Aug-2017 19:29:02.016 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M22
16-Aug-2017 19:29:02.021 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
16-Aug-2017 19:29:02.027 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
16-Aug-2017 19:29:02.028 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 32 ms
Connected to server
[2017-08-16 07:29:02,475] Artifact questions-websystique:war exploded: Artifact is being deployed, please wait...
16-Aug-2017 19:29:03.341 INFO [RMI TCP Connection(3)-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.
16-Aug-2017 19:29:03.420 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
16-Aug-2017 19:29:03.482 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Wed Aug 16 19:29:03 CEST 2017]; root of context hierarchy
16-Aug-2017 19:29:03.537 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions Registering annotated classes: [class com.websystique.springmvc.configuration.AppConfig]
16-Aug-2017 19:29:04.001 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName Loaded JDBC driver: com.mysql.jdbc.Driver
16-Aug-2017 19:29:04.137 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations 4.0.5.Final
16-Aug-2017 19:29:04.143 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.Version.logVersion HHH000412: Hibernate Core 4.3.6.Final
16-Aug-2017 19:29:04.146 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
16-Aug-2017 19:29:04.148 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.cfg.Environment.buildBytecodeProvider HHH000021: Bytecode provider name : javassist
16-Aug-2017 19:29:04.463 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
16-Aug-2017 19:29:04.588 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.engine.transaction.internal.TransactionFactoryInitiator.initiateService HHH000399: Using default transaction strategy (direct JDBC transactions)
16-Aug-2017 19:29:04.593 INFO [RMI TCP Connection(3)-127.0.0.1] org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory.<init> HHH000397: Using ASTQueryTranslatorFactory
16-Aug-2017 19:29:04.824 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@2d15b144] of Hibernate SessionFactory for HibernateTransactionManager
16-Aug-2017 19:29:04.972 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod Mapped "[//],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public java.lang.String com.websystique.springmvc.controller.AppController.mainPage(org.springframework.ui.ModelMap)
16-Aug-2017 19:29:04.972 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod Mapped "[//processForm],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public java.lang.String com.websystique.springmvc.controller.AppController.processAnswers(javax.servlet.http.HttpServletRequest,org.springframework.ui.Model)
16-Aug-2017 19:29:04.973 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod Mapped "[//questionlist],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public org.springframework.web.servlet.ModelAndView com.websystique.springmvc.controller.AppController.showQuestionList()
16-Aug-2017 19:29:05.027 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization completed in 1607 ms
16-Aug-2017 19:29:05.034 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'dispatcher': initialization started
16-Aug-2017 19:29:05.037 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.prepareRefresh Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Aug 16 19:29:05 CEST 2017]; parent: Root WebApplicationContext
16-Aug-2017 19:29:05.056 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'dispatcher': initialization completed in 22 ms
[2017-08-16 07:29:05,066] Artifact questions-websystique:war exploded: Artifact is deployed successfully
[2017-08-16 07:29:05,066] Artifact questions-websystique:war exploded: Deploy took 2 591 milliseconds
16-Aug-2017 19:29:12.022 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager]
16-Aug-2017 19:29:12.041 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager] has finished in [18] ms
您已经在类级别上映射了/
,因此您无需在方法级别上再次映射它。你这样做意味着尝试访问//
上的资源,这不仅是可能的。这是因为方法上的map与类上的map相关。
所以只需用控制器类的mainPage方法替换@RequestMapping(value = "/")
@RequestMapping
或者
@RequestMapping(value = "")
或者
@RequestMapping(method = RequestMethod.GET)
我找到了解决方案我的.jsp文件中有2个没有taglibs。我添加了这个:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
Spring 4.0.6.RELEASE以某种方式在没有它们的情况下工作。
以上是关于Spring mvc annotation配置。升级到弹簧4.3.9时出错404的主要内容,如果未能解决你的问题,请参考以下文章
Spring MVC 初始化源码—<mvc:annotation-driven >配置标签的源码解析
springMVC配置文件spring-servlet.xml中<mvc:annotation-driven />的意义
Spring mvc annotation配置。升级到弹簧4.3.9时出错404