我目前正在从事两个 Maven 项目;项目数据和项目库。project-data 依赖于 pom 中定义的 project-base 为
<dependency>
<groupId>com.tura.jetty</groupId>
<artifactId>project-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
对于 java 文件,一切正常,我可以在项目数据类中导入并引用项目库中的类。问题是,我还必须处理项目库中定义的 Groovy 类的依赖关系。当我尝试从项目数据中的 groovy 类中引用项目库中定义的 groovy 类时,出现“Groovy:无法解析类”错误。我尝试将我的 groovy 类移动到 src/main/groovy 但错误仍然存在。为了使依赖它的项目可以使用基于项目的 groovy 类,我还需要做些什么吗?
作为参考,以下是我的 pom.xml 文件中的一些片段。我正在使用档案服务器来存储我的自定义库。
项目基础
<project>
<groupId>com.tura.jetty</groupId>
<artifactId>project-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.7</source>
<target>1.7</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.1-01</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.1</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
项目数据
<project>
<artifactId>project-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.7</source>
<target>1.7</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.1-01</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.tura.jetty</groupId>
<artifactId>project-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>