我使用带有netbeans的自动生成的实体类创建了一个RESTful Web服务。我也用过maven。我在tomcat 8中将其部署为localhost。我确实看到了索引页面,但我无法访问任何端点。我最初在Glassfish服务器上本地运行它,它工作正常。 我尝试在netbeans中测试资源uri,但它说,
无法打开资源网址:localhost:8080 // api / activity
这是来自apache tomcat的我的server.xml文件。
<?xml version="1.0" encoding="UTF-8"?>
--><Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>
<Context antiJARLocking="true" docBase="C:\xxx\yyyy\apache-tomcat-8.0.36\apache-tomcat-8.0.36\wtpwebapps\xxDBWithMaven" path="/VoyateDBWithMaven" reloadable="true" source="org.eclipse.jst.jee.server:VoyateDBWithMaven"/></Host>
</Engine>
</Service>
</Server>
无论如何,我可以解决这个问题,以便可以访问资源吗?这很混乱,因为部署了应用程序并显示了索引文件。
答案 0 :(得分:0)
无法打开资源网址:localhost:8080 // api / activity
“localhost:8080”和“api / activity”之间有两个斜杠。在您指定路径的配置中删除一个:api/activity
而不是/api/activity
。