Jak*_*sky 5 java spring tomcat maven http-status-code-404
我的Tomcat status code 404上部署的每个应用程序都会在我发出的每个请求中返回 我尝试过几个项目,helloworlds或者骷髅,每个项目的行为与其他项目相同:
我用过的一些项目:
https://github.com/mwarman/skeleton-ws-spring-boot
https://spring.io/guides/gs/rest-service/(我可以运行它,mvn spring-boot:run但它不能部署到Tomcat)
https://github.com/shagstrom/spring-mvc-hibernate-skeleton
我正在使用最新的Tomcat8 (8.0.27),Oracle JDK 8.我也试过Tomcat7了OpenJDK 7.使用的Tomcats在MAC和Debian上运行.我通过mvn和Intellij Idea构建应用程序.
Tomcats很干净,没有更改配置(除了添加manager-gui用户).
由于我尝试了很多不同的项目,我不相信代码中存在问题.它是在Tomcat的配置中吗?我怎样才能让它发挥作用?
编辑:
server.xml代码:
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->
        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
      </Host>
    </Engine>
  </Service>
</Server>
小智 0
如果您成功安装了 tomcat,您可能已经从浏览器http://localhost:8080/ URL看到了 tomcat 主页。(否则,需要先检查tomcat安装。)
我想您可能已经通过您提到的上述网站构建了 jar。我想知道您是否将该 jar 应用于您的 tomcat 中,因为您提到了任何其他项目的相同结果。为了应用java程序,你需要将jar或war应用到你的tomcat中。
以下是我希望对您有所帮助的链接。
打包war:如何在Eclipse中制作war文件
Tomcat - war 文件部署:https://www.youtube.com/watch?v=9X9DA8oVodk
| 归档时间: | 
 | 
| 查看次数: | 978 次 | 
| 最近记录: |