我正在使用 datanucleus/mongodb。我最近在 Eclipse 中将我的动态 Web 项目转换为 maven,因为我想使用 maven buildnumber 插件。但是我只是想让它现在在 Maven 中工作。让我的简单项目使用 Eclipse 编译和运行没有问题。
我的项目分为 3 - main、LibA、LibAA。
Main 依赖/使用 LibA 中的内容(或直接来自 LibAA),而 LibA 依赖/使用来自 LibAA 的内容。LibAA 不知道其他项目。
示例:LibAA - DObject 数据类文件 LibA - DRemote 从 DObject 继承 Main - DStaff 从 DObject 继承
这就是我在 Pom xml 中设置依赖项的方式。
所以这里的问题是,每当我在主项目中尝试 mvn clean package/install 时,我总是会为从 LibAA 继承的数据类文件找到符号。
Datanucleus 查询说 DStaff 已重命名为 QDStaff,然后再往下走,它说找不到 DObject。是不是因为 DObject 在内部也被重命名为 QDObject,所以再找也来不及了?
2个问题。
1:为什么我的数据文件被重命名。即在前面添加了一个 Q 字符 2:尽管调用了 datanucleus 增强器并正确设置了依赖项,为什么我仍然收到符号未找到错误?我对独立数据类文件没有任何问题,但只有那些继承 DObject 的是 LibAA 项目。
我好像错过了什么。。
任何见解都值得赞赏。
编辑:添加了一个示例部分编译日志(删除了大部分类似的错误/日志)
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ MyMainProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 591 source files to /Users/rhs/gitnew/MyMainProject/MyMainProject/target/classes
DataNucleus : JDO Query - com.rhs.kms.data.DServerSettingRecord -> com.rhs.kms.data.QDServerSettingRecord
DataNucleus : JDO Query - com.rhs.kms.data.account.DStaffAccount -> com.rhs.kms.data.account.QDStaffAccount
DataNucleus : JDO Query - com.rhs.kms.data.DMenu -> com.rhs.kms.data.QDMenu
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/account/QDStaffAccount.java:[6,55] cannot find symbol
symbol: class QAuthAccount
location: package com.rhslib.account
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/QDTableOrderingSettings.java:[6,65] cannot find symbol
symbol: class QDObject
location: package com.rhslib.database
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.056 s
[INFO] Finished at: 2015-09-14T16:25:40+08:00
[INFO] Final Memory: 25M/300M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project MyMainProject: Compilation failure: Compilation failure:
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/account/QDStaffAccount.java:[6,55] cannot find symbol
[ERROR] symbol: class QAuthAccount
[ERROR] location: package com.rhslib.account
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/kms/data/QMenu.java:[6,47] cannot find symbol
[ERROR] symbol: class QDObject
[ERROR] location: package com.rhslib.database
edit2:这是一个文件损坏的示例(取自 target/generated-sources/annotations/*)
package com.rhs.data.ARM;
import javax.jdo.query.*;
import org.datanucleus.api.jdo.query.*;
public class QDAccountApp extends com.rhslib.database.QDObject //error starts from QDObject
要进行迭代,DAccountApp 存在于主项目中。主项目依赖于名为 KMSLib 的库,而 KMSLib 依赖于名为 RHSLib 的项目。我曾尝试使 Main 项目直接依赖于这两个项目,但无济于事。
edit3:从我的主项目中附加了我的 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>MainProject</groupId>
<artifactId>MainProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>MainProject</name>
<properties>
<maven.build.timestamp.format>yyyy/MM/dd hh:mm:ss a</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<encoding>UTF-8</encoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.1</version>
<configuration>
<api>JDO</api>
<props>${basedir}/datanucleus.properties</props>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>KMSLib</groupId>
<artifactId>KMSLib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-manifests</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>DN_M2_Repo</id>
<name>DataNucleus Repository</name>
<url>http://www.datanucleus.org/downloads/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>DataNucleus_2</id>
<url>http://www.datanucleus.org/downloads/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
edit4:附上我的 .classpath 文件
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 8.x Runtime">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>