Java 为嵌入式类编译Maven错误
我有一个数据类Java 为嵌入式类编译Maven错误,java,eclipse,mongodb,maven,datanucleus,Java,Eclipse,Mongodb,Maven,Datanucleus,我有一个数据类DPOSTerminalRecord。我在里面有一个名为LimitedList的嵌入式数据类。我正在使用DataNucleus JDO for MongoDB和DN增强器 执行mvn clean package命令时,我得到以下信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project MainPr
DPOSTerminalRecord
。我在里面有一个名为LimitedList
的嵌入式数据类。我正在使用DataNucleus JDO for MongoDB和DN增强器
执行mvn clean package
命令时,我得到以下信息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project MainProject: Compilation failure
[ERROR] /Users/rhs/git/Project/MainProject/target/generated-sources/annotations/com/rhs/data/QDPOSTerminalRecord.java:[32,53] cannot find symbol
[ERROR] symbol: class QLimitedList
[ERROR] location: class com.rhs.data.DPOSTerminalRecord
你知道我该怎么解决这个问题吗?我在QDPOSTerminalRecord.java
文件中没有看到LimitedList
类。我在Eclipse编译中对此没有任何问题,只有Maven有问题。在Eclipse中,日志显示,com.rhs.data.DPOSTerminalRecord$LimitedClass
正在增强。我错过了什么
编辑:添加了我的类的快速视图
@PersistenceCapable
public class DPOSTerminalRecord {
@PrimaryKey
private String _id; // this is the device ID
private String _name; // this is the last logged name for the device
@PersistenceCapable
@EmbeddedOnly
private static class LimitedList<E> // the limited list type automatically dumps the last object out of the list when the capacity is reached.
{
@Persistent
int capacity;
@Persistent
private ArrayList<E> list;
public LimitedList(int initialCapacity) {
capacity = initialCapacity;
list = new ArrayList<E>(capacity);
}
public boolean add(E e)
{
if(list.size() == capacity)
{
// dump the last object
list.remove(capacity - 1);
}
return list.add(e);
}
}
@Embedded(members={
@Persistent(name="capacity", column="capacity"),
@Persistent(name="list", column="list")
})
@Persistent
private LimitedList<String> m_knownNames = new LimitedList<String>(5);
public DPOSTerminalRecord(String id, String name) {
super();
_id = id;
_name = name;
}
...etc
@PersistenceCapable
公共类数据最终记录{
@主键
私有字符串_id;//这是设备id
私有字符串_name;//这是设备最后记录的名称
@持久的
@仅嵌入
private static class LimitedList//limited list类型在达到容量时自动从列表中转储最后一个对象。
{
@持久的
国际能力;
@持久的
私有数组列表;
公共限制列表(初始容量){
容量=初始容量;
列表=新阵列列表(容量);
}
公共布尔加法(E)
{
if(list.size()=容量)
{
//转储最后一个对象
列表。删除(容量-1);
}
返回列表。添加(e);
}
}
@嵌入式(成员)={
@持久性(name=“capacity”,column=“capacity”),
@持久性(name=“list”,column=“list”)
})
@持久的
私有限制列表m_knownNames=新限制列表(5);
公共DPOSTerminalRecord(字符串id、字符串名称){
超级();
_id=id;
_名称=名称;
}
等
edit2:添加了生成的类
package com.rhs.data;
import javax.jdo.query.*;
import org.datanucleus.api.jdo.query.*;
public class QDPOSTerminalRecord extends PersistableExpressionImpl<DPOSTerminalRecord> implements PersistableExpression<DPOSTerminalRecord>
{
public static final QDPOSTerminalRecord jdoCandidate = candidate("this");
public static QDPOSTerminalRecord candidate(String name)
{
return new QDPOSTerminalRecord(null, name, 5);
}
public static QDPOSTerminalRecord candidate()
{
return jdoCandidate;
}
public static QDPOSTerminalRecord parameter(String name)
{
return new QDPOSTerminalRecord(DPOSTerminalRecord.class, name, ExpressionType.PARAMETER);
}
public static QDPOSTerminalRecord variable(String name)
{
return new QDPOSTerminalRecord(DPOSTerminalRecord.class, name, ExpressionType.VARIABLE);
}
public final StringExpression _id;
public final StringExpression _name;
public final com.rhs.data.DPOSTerminalRecord.QLimitedList m_knownNames; // This is the infringing line since there is no QLimitedList inside this file
public QDPOSTerminalRecord(PersistableExpression parent, String name, int depth)
{
super(parent, name);
this._id = new StringExpressionImpl(this, "_id");
this._name = new StringExpressionImpl(this, "_name");
if (depth > 0)
{
this.m_knownNames = new com.rhs.data.DPOSTerminalRecord.QLimitedList(this, "m_knownNames", depth-1);
}
else
{
this.m_knownNames = null;
}
}
public QDPOSTerminalRecord(Class type, String name, ExpressionType exprType)
{
super(type, name, exprType);
this._id = new StringExpressionImpl(this, "_id");
this._name = new StringExpressionImpl(this, "_name");
this.m_knownNames = new com.rhs.data.DPOSTerminalRecord.QLimitedList(this, "m_knownNames", 5);
}
}
package com.rhs.data;
导入javax.jdo.query.*;
导入org.datanucleus.api.jdo.query.*;
公共类QDPOSTerminalRecord扩展PersistableExpressionImpl实现PersistableExpression
{
公共静态最终QDPOSTerminalRecord jdoCandidate=候选(“此”);
公共静态QDPOSTerminalRecord候选(字符串名称)
{
返回新的QDPOSTerminalRecord(null,name,5);
}
公共静态QDPOSTerminalRecord候选项()
{
返回jdoCandidate;
}
公共静态QDPOSTerminalRecord参数(字符串名称)
{
返回新的QDPOSTerminalRecord(DPOSTerminalRecord.class、name、ExpressionType.PARAMETER);
}
公共静态QDPOSTerminalRecord变量(字符串名称)
{
返回新的QDPOSTerminalRecord(DPOSTerminalRecord.class、name、ExpressionType.VARIABLE);
}
公共最终表达_id;
公共最终表达式_名称;
public final com.rhs.data.DPOSTerminalRecord.QLimitedList m_knownNames;//这是侵权行,因为此文件中没有QLimitedList
公共QDPOSTerminalRecord(PersistableExpression父级、字符串名称、整数深度)
{
超级(家长、姓名);
this._id=new StringExpressionImpl(this,“_id”);
此._name=new StringExpressionImpl(此,“_name”);
如果(深度>0)
{
this.m_knownNames=new com.rhs.data.DPOSTerminalRecord.QLimitedList(此“m_knownNames”,depth-1);
}
其他的
{
this.m_knownNames=null;
}
}
公共QDPOSTerminalRecord(类类型、字符串名称、ExpressionType ExprtType)
{
super(类型、名称、exprType);
this._id=new StringExpressionImpl(this,“_id”);
此._name=new StringExpressionImpl(此,“_name”);
this.m_knownNames=new com.rhs.data.DPOSTerminalRecord.QLimitedList(此“m_knownNames”,5);
}
}
问题出在QDPOSTerminalRecord.java:[32,53]
-有什么?(我假设是第32行,第53列…)它引用的是QLimitedList
。我已经将生成的源文件附加到Edit2下以供参考。好的,这让事情更清楚了。你必须在这里使用嵌套类吗?你能不能让它成为一个顶级类?这感觉像是解决问题的最简单方法。将LimitedList放在一个单独的类文件中好我为JDO查看的文档typesafe查询表示不支持内联静态持久类