如何为Maven项目添加缺少的依赖项

时间:2018-12-31 05:44:36

标签: eclipse maven http tomcat web

我正在尝试在eclipse中运行我的Rest http服务器,并且出现以下错误。我不知道该如何解决。我尝试更改为项目目录并输入mvn dependency:resolve,但是它不起作用。

SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.message(java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException at parameter at index 0
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.message(java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException at parameter at index 1
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.message(java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException at parameter at index 2
  SEVERE: Method, public org.json.JSONObject serverPackage.ServerInRest.message(java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException, annotated with PUT of resource, class serverPackage.ServerInRest, is not recognized as valid resource method.
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.leaveRoom(java.lang.String,java.lang.String) throws java.io.IOException at parameter at index 0
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.leaveRoom(java.lang.String,java.lang.String) throws java.io.IOException at parameter at index 1
  SEVERE: Method, public org.json.JSONObject serverPackage.ServerInRest.leaveRoom(java.lang.String,java.lang.String) throws java.io.IOException, annotated with PUT of resource, class serverPackage.ServerInRest, is not recognized as valid resource method.
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.joinRoom(java.lang.String,java.lang.String) at parameter at index 0
  SEVERE: Missing dependency for method public org.json.JSONObject serverPackage.ServerInRest.joinRoom(java.lang.String,java.lang.String) at parameter at index 1
  SEVERE: Method, public org.json.JSONObject serverPackage.ServerInRest.joinRoom(java.lang.String,java.lang.String), annotated with PUT of resource, class serverPackage.ServerInRest, is not recognized as valid resource method.

下面有另一个错误,我认为一旦我修复此错误便可以解决

org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
com.sun.jersey.spi.inject.Errors$ErrorMessagesException

这是我的web.xml文件 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>RestServer</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
    <servlet>       
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>serverPackage</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/serv/*</url-pattern>
    </servlet-mapping>
</web-app>

这是我的pom.xml文件 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>RestServer</groupId>
  <artifactId>RestServer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>

    </plugins>
  </build>
  <dependencies>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20170516</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.6</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.3.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>
    </dependencies> 
</project>

0 个答案:

没有答案