我将一些现有项目从 ant 更改为 maven 项目。
到现在为止还挺好。

所有项目都具有相同的 groupId。
有一个名为“ServerBase”和 artifactId 为“server-base”的项目。
在这个项目中有一个抽象类“BaseService”,它通过以下方式定义了一个记录器:

import org.jboss.logging.Logger; 
[...] 
protected Logger log = Logger.getLogger(this.getClass()); 

还有另一个名为“Server”和 artifactId 为“server”的项目。
在这个项目中,有一个类 ConfigurationDAOImpl 扩展了上面的 BaseService-Class。
在 ConfigurationDAOImpl 中,记录器日志用于创建一些输出。

在“服务器”的 POM 文件中,我已经声明:
    <dependency> 
        <groupId>com.tcom.amadeus</groupId> 
        <artifactId>server-base</artifactId> 
        <version>${project.version}</version> 
    </dependency> 

在 BuildPath 下,MavenDependencies 下的依赖关系非常好。我之前从构建路径中删除了旧的 dirct/natural/ant-dependency。
如果我删除它,我会收到很多关于缺少类等的错误。
但是,尽管我确实有这种依赖性,但我在 Eclipse 中遇到了以下错误(在选项卡标记下):
The type org.apache.commons.logging.Log cannot be resolved. It is indirectly referenced from required .class files 
 
Resource: ConfigurationDAPImpl.java 
 
Path: /Server/src/main/... 
 
Location: Line 24 
 
Type: Java Problem 

我尝试删除依赖项并再次添加它,但没有任何运气。
这两个项目都引用了 JAVA 1.8。
这两个项目都已构建,目标是多次清理包。
两个项目都已通过 Rightclick 或按 F5 更新。
我正在使用 Eclipse 版本:Neon.1a Release (4.6.1)
我正在使用 apache-maven-3.3.9
我正在使用 m2e 插件。

任何进一步的帮助将不胜感激。
提前致谢。

请您参考如下方法:

有两种方法可以“解决”这个问题:

1)
在 server-projects pom-file 中显式添加所需的依赖项:

<dependency> 
  <groupId>org.jboss.logging</groupId> 
  <artifactId>jboss-logging</artifactId> 
</dependency> 

2)
将 server-base-projects pom 文件中所需依赖项的范围从现在“提供”更改为“编译”或完全删除范围标记,以便 maven 使用默认范围(我猜是“编译” ')

老的:
<dependency> 
  <groupId>org.jboss.logging</groupId> 
  <artifactId>jboss-logging</artifactId> 
  <scope>provided</scope> 
</dependency> 

新的:
<dependency> 
  <groupId>org.jboss.logging</groupId> 
  <artifactId>jboss-logging</artifactId> 
  <scope></scope> 
</dependency> 

或者:
<dependency> 
  <groupId>org.jboss.logging</groupId> 
  <artifactId>jboss-logging</artifactId> 
</dependency> 

文档中的一些背景:

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies

provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.



谢谢大家。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!