javax.xml.namespace 包可从多个模块访问:<unnamed>、eclipse webservice 中的 java.xml

dav*_*ave 6 java eclipse web-services

我在 Eclipse 动态项目中运行分数和 Scoreservices 类,我创建了一个 Web 服务并运行它,但它给了我错误消息The package javax.xml.namespace is accessible from more than one module: <unnamed>, java.xml。不知道如何处理这个输出

分数等级

package startAgain;

import javax.xml.bind.annotation.*;
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class Score {
public int wins, losses, ties;
}   
Run Code Online (Sandbox Code Playgroud)

分数服务类

package startAgain;

import javax.ejb.*;
import javax.jws.*;
@Stateless
@WebService
public class ScoreService {
private static Score score = new Score();
public Score updateScore (int wins, int losses, int ties) {
    score.wins = wins;
    score.losses = losses;
    score.ties = ties;
    return score;
}
@WebMethod(operationName="resetScore")
public void reset() {
score.wins = score.losses = score.ties = 0;
}
        public Score getScore() { return score; }
        public int increaseWins() { return score.wins++; }
        public int increaseTies() { return ++score.ties; }
        public int increaseLosses() { return ++score.losses; }
        public int getWins() { return score.wins; }
        public int getTies() { return score.ties; }
        public int getLosses() { return score.losses; }

}
Run Code Online (Sandbox Code Playgroud)

有关清除此包 javax.xml.namespace 错误的任何帮助谢谢

小智 1

几天前我在 Eclipse 中遇到了同样的问题。

因此,我试图找到提出了Java 内置模块javax.xml.namespace中已经可用的相同包 ( ) 的库,从而引发了包重复。javax.xml

就我而言,它是一个名为 的图书馆stax-api。我刚刚将其从构建中删除,如下所示:

dependencies {
...
  configurations {
       compile.exclude group: 'stax', module: 'stax-api'
  }
...
}
Run Code Online (Sandbox Code Playgroud)