【java】IDEA 本地启动web项目访问任何地址都是404

控制台输出如下,没有报错:

    D:\apache-tomcat-8.0.30\bin\catalina.bat run

[2018-04-26 02:19:05,295] Artifact PersonAnalysisBS:war exploded: Waiting for server connection to start artifact deployment...

Using CATALINA_BASE: "C:\Users\William\.IntelliJIdea2017.2\system\tomcat\Unnamed_PersonAnalysisBS_2"

Using CATALINA_HOME: "D:\apache-tomcat-8.0.30"

Using CATALINA_TMPDIR: "D:\apache-tomcat-8.0.30\temp"

Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_151"

Using CLASSPATH: "D:\apache-tomcat-8.0.30\bin\bootstrap.jar;D:\apache-tomcat-8.0.30\bin\tomcat-juli.jar"

26-Apr-2018 14:19:06.622 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.30

26-Apr-2018 14:19:06.623 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 1 2015 22:30:46 UTC

26-Apr-2018 14:19:06.623 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.30.0

26-Apr-2018 14:19:06.624 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10

26-Apr-2018 14:19:06.624 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0

26-Apr-2018 14:19:06.624 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64

26-Apr-2018 14:19:06.624 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_151\jre

26-Apr-2018 14:19:06.624 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_151-b12

26-Apr-2018 14:19:06.625 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\William\.IntelliJIdea2017.2\system\tomcat\Unnamed_PersonAnalysisBS_2

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: D:\apache-tomcat-8.0.30

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms2048m

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx2048m

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:PermSize=64M

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxPermSize=128M

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099

26-Apr-2018 14:19:06.626 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\William\.IntelliJIdea2017.2\system\tomcat\Unnamed_PersonAnalysisBS_2\conf\logging.properties

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.0.30\endorsed

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\William\.IntelliJIdea2017.2\system\tomcat\Unnamed_PersonAnalysisBS_2

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\apache-tomcat-8.0.30

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\apache-tomcat-8.0.30\temp

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.

26-Apr-2018 14:19:06.627 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

26-Apr-2018 14:19:07.771 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)

26-Apr-2018 14:19:08.042 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]

26-Apr-2018 14:19:08.055 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]

26-Apr-2018 14:19:08.057 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1982 ms

26-Apr-2018 14:19:08.129 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina

26-Apr-2018 14:19:08.129 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30

26-Apr-2018 14:19:08.166 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]

26-Apr-2018 14:19:08.176 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]

26-Apr-2018 14:19:08.177 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 119 ms

Connected to server

[2018-04-26 02:19:08,531] Artifact PersonAnalysisBS:war exploded: Artifact is being deployed, please wait...

26-Apr-2018 14:19:24.282 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.

[2018-04-26 02:19:24,414] Artifact PersonAnalysisBS:war exploded: Artifact is deployed successfully

[2018-04-26 02:19:24,414] Artifact PersonAnalysisBS:war exploded: Deploy took 15,883 milliseconds

tomcat设置如下:

【java】IDEA 本地启动web项目访问任何地址都是404

【java】IDEA 本地启动web项目访问任何地址都是404
spring设置入下图:

【java】IDEA 本地启动web项目访问任何地址都是404

搜索得到的各种结果已尝试的有:
1:保证系统的JDK和项目JDK版本一致,且在有多个JDK版本的时候,保证系统JAVA_HOME的JDK变量版本与项目版本一致。
2:web.xml中配置spring的启动Listener代码如下:

<listener>

<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>

</listener>

<listener>

<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>

</listener>

<!-- spring容器启动监听器 -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

3:pom.xml中的添加了web.xml,保证了可以加载,代码如下:

        <plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.1.1</version>

<configuration>

<packagingExcludes>WEB-INF/web.xml</packagingExcludes>

<webResources>

<resource>

<directory>${runtime.active}</directory>

<targetPath>WEB-INF/classes</targetPath>

</resource>

</webResources>

</configuration>

</plugin>

现在想请教一下有没有人能知道错误在哪儿啊?
这个问题卡了差不多三天了,各种查资料和问题都尝试过了,而且代码在别人的电脑上本地能跑,在我电脑上就不行了。
谢谢大家了!

回答

你的项目是从这里启动的

C:\Users\William\.IntelliJIdea2017.2\system\tomcat\Unnamed_PersonAnalysisBS_2

你要查看一下项目是完整发布到这个目录下了。

你可以用IDE向导创建一个新项目,确保成正常访问,然后逐步把你的项目文件迁到这个新项目下,看是哪里出了问题。

截图看一下artifacts配置项

你最后怎么解决的我现在也卡在这

以上是 【java】IDEA 本地启动web项目访问任何地址都是404 的全部内容, 来源链接: utcz.com/a/73583.html

回到顶部