场景:
我有一个主级项目A和A,两个子项目B和C由不同的开发人员工作,但他们同意通过通用接口的抽象.
B取决于C(依赖性).在B的pom我添加了
<dependency> .. details of project C..</dependency> .
Run Code Online (Sandbox Code Playgroud)
这样做,maven插入依赖项很好,除了不重新编译项目C.
我希望项目C在每次编译时自动重新编译.
当我尝试调用100%正常工作的代码时,我从eclipse中得到错误.例如,它在我的netbeans中工作,但不是这个eclipse项目.错误是荒谬的,我几乎可以肯定它是由我正在使用的OPEN JPA的一些Maven依赖引起的.有什么指针吗?
Map<String,String> properties = new HashMap<String,String>();
properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "");
properties.put(PersistenceUnitProperties.JDBC_USER, "root");
properties.put(PersistenceUnitProperties.JDBC_URL, "jdbc:mysql://localhost:3306/mydb");
properties.put(PersistenceUnitProperties.JDBC_DRIVER, "com.mysql.jdbc.Driver");
emf = Persistence.createEntityManagerFactory("Persistentunitname", properties);
Run Code Online (Sandbox Code Playgroud)
错误发生在最后一行,错误是:
ClassFormat错误"在类文件javax/persistence/Persistence中不是本机或抽象的方法中的Absent Code属性"
简单的问题,但我用了一个多小时.我的代码如下.我需要让SomeClass sc动态化.因此,您将类名作为字符串传递给函数,并使用该类代替静态someClass.怎么去呢?
SomeClass sc;
if (someOtherClassObject instanceof SomeClass){
sc=(SomeClass) someOtherClassObject;
Run Code Online (Sandbox Code Playgroud)
我想要的是
public void castDynamic (String strClassName){
//cast the classname referred by strClassName to SomeClass
//if it is the instance of SomeClass
}
Run Code Online (Sandbox Code Playgroud)
编辑:以上是简化.实际的代码就是这个
public void X(String className, RequestInterface request)
{
//My current code is this, I need to change so that "XRequest"
//can be any class referred by "className",
//and "request.getRequest" the object belonging to "className" class
//I don't want static XRequest xvr, it should be fetched dynamically
XRequest xvr; …Run Code Online (Sandbox Code Playgroud) 我的TableX参考了TableY.
@JoinColumn(name = "idTableY", referencedColumnName = "idTableY")
@ManyToOne(optional = false, fetch=FetchType.LAZY)
private TableY idTableY;
Run Code Online (Sandbox Code Playgroud)
我收到这个错误.
<openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.persistence.ArgumentException
"com.mycompany.entities.TableX.idTableY" has columns with targets, but OpenJPA does not support any joins on this mapping in this context.
Run Code Online (Sandbox Code Playgroud)
表Y有这个代码:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idTableY")
private Collection<TableX> tableXCollection;
Run Code Online (Sandbox Code Playgroud)
这个生成的eclipse-link代码是100%正常的(所有其他具有类似代码的实体/表都没有问题).
但其中有几个正在犯这样的错误.知道为什么吗?
嗨,我有一个为轻量级需求而编写的自定义Web服务器.现在我需要HTTP用户提供会话支持.任何指南都会有所帮助.请注意,我没有使用任何servlet.