我使用netbeans自动生成的实体类创建了一个RESTful web服务。我还使用了maven。我将其部署在tomcat 8中作为localhost。我确实看到了索引页,但我无法访问任何端点。我最初在Glassfish服务器上本地运行这个,它工作得很好。我尝试在netbeans中测试资源uri,但它说,
无法打开资源URL: localhost:8080//api/activity
这是我的server.xml文件从apache tomcat.
<?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:xxxyyyyapache-tomcat-8.0.36apache-tomcat-8.0.36wtpwebappsxxDBWithMaven" path="/VoyateDBWithMaven" reloadable="true" source="org.eclipse.jst.jee.server:VoyateDBWithMaven"/></Host>
</Engine>
</Service>
</Server>
是否有办法解决这个问题,以便可以访问资源?这很令人困惑,因为应用程序被部署,索引文件被显示。
无法打开资源URL: localhost:8080//api/activity
在"localhost:8080"one_answers"api/activity"之间有两个斜杠。删除配置中指定路径的一个:api/activity
而不是/api/activity
。