1
我有麻煩爲我的桌面應用程序部署一個示例web服務到tomcat。如何將jax-rs web服務部署到apache tomcat?
這裏是我的班
AppConfig.java
@ApplicationPath("sample-ws")
public class AppConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<Class<?>>();
resources.add(HelloWorld.class);
return resources;
}
}
HelloWorld.java
@Path("hello-world")
public class HelloWorld {
@GET
public String hello(){
return "hello world";
}
}
的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>com.sample</groupId>
<artifactId>sample-ws</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<finalName>sample-ws</finalName>
</build>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
我不知道寫什麼在我的web.xml中,我可以'不要讓這件事情起作用。我錯過了什麼?
P.S.如果這很重要,我使用apache-tomcat-8.0.23