简体   繁体   English

Maven 动态 Web 在 pom.xml 文件中定义的项目依赖项不起作用

[英]Maven Dynamic Web Project dependencies defined in pom.xml file not working

I have a university project which involves setting up multiple Java Eclipse Dynamic Web Projects.我有一个大学项目,其中涉及设置多个 Java Eclipse 动态 Web 项目。 These projects require JAXWS annotations which are set up by adding a couple of properties and dependencies into the pom.xml file of the project.这些项目需要通过在项目的 pom.xml 文件中添加几个属性和依赖项来设置 JAXWS 注释。

<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>com.sun.org.apache.xml.internal</groupId>
        <artifactId>resolver</artifactId>
        <version>20050927</version>
    </dependency>
</dependencies>

Upon trying to use the JAX-WS annotations required (@WebService, @WebResult, etc.) in the project's Java interface I get an error message stating ie " "WebService" cannot be resolved to a type".尝试在项目的 Java 界面中使用所需的 JAX-WS 注释(@WebService、@WebResult 等)时,我收到一条错误消息,指出“无法将“WebService”解析为类型”。 I have tried manually importing these libraries into the interface class (ie import javax.jws.WebService) but get an error message "The import javax.jws cannot be resolved".我尝试将这些库手动导入接口 class(即导入 javax.jws.WebService),但收到错误消息“无法解析导入 javax.jws”。

My lecturer has stated that the only reason he can think of the annotations not working is if the dependencies haven't been added, even though I've done that?我的讲师说过,他认为注释不起作用的唯一原因是如果没有添加依赖项,即使我已经这样做了? It's really confusing me, any help would be much appreciated.这真的让我很困惑,任何帮助将不胜感激。

You are not using the correct dependency for WebService , WebResult您没有使用正确的WebService依赖项, WebResult

Try this:尝试这个:

<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.2.6</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM