我创建了两个实体Bean,当用户登录和向用户计费时,它们会将用户数据插入mysql数据库。我决定使用Ebean ORM,因为它只是表插入的“轻量级”。
该应用程序是基于Maven的soap cxf war,已部署到weblogic 12.2.1应用服务器并在eclipse 2019-06-R xxx上开发。
单元测试工作正常,因为将数据插入到测试数据库中,当在eclipse的主类中执行代码时,代码也持久保存在普通数据库中,而我没有得到这个“ bean增强错误”。 ”
但是,在调用bean的insert方法的位置建立了基于数据库的连接后,生成的战争失败并显示“ bean not not not error ...”。
我该如何解决?
基于Ebean的官方网站,我遵循了本教程,从设置到Eclipse和Maven配置:
以前的问题主要针对Play框架,例如,与我的问题无关。
https://groups.google.com/forum/#!topic/ebean/gdgGGVd0K5E
我已经更新了pom.xml,application.yml和ebean.mf,如github示例所示:
https://github.com/ebean-orm/examples/tree/master/base-example
在命令行中运行了mvn clean install,并进行了重新部署,但是即使在单元测试和Java主类中位于本地,数据仍被插入到数据库中
安装并启用Ebean Enhacer 11.x插件
日食记录:
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:46.453 !MESSAGE ebean v11 +清单软件包-实体:[registration.audit.model]事务性:[] querybean:[registration.audit.model]
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:48.990 !MESSAGE ... EnhanceDebugLevel:1
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.014 !MESSAGE ...找到了ebean清单文件
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.024 !MESSAGE ebean v11 +清单软件包-实体:[registration.audit.model]事务性:[] querybean:[registration.audit.model,registration.audit.model]
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.038 !MESSAGE ... ebean-enhance> cls:注册/审核/模型/票据msg:增强
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.053 !MESSAGE增强:注册/审核/模型/帐单
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.059 !MESSAGE ... ebean-enhance> cls:注册/审核/模型/登录msg:增强
pom.xml:
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.12</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>org.avaje.tile:java-compile:1.1</tile>
<tile>io.ebean.tile:enhancement:11.39.1</tile>
</tiles>
</configuration>
</plugin>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>11.38.1</version>
</dependency>
<!-- support for query beans -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>11.38.1</version>
</dependency>
<!-- java annotation processor to generate query beans -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>11.38.1</version>
<scope>provided</scope>
</dependency>
ebean.mf:
entity-packages: za.gov.deeds.registration.audit.model
transactional-packages: za.gov.deeds.registration.service.audit
querybean-packages: za.gov.deeds.registration.service.audit
profile-location: true
application.yml:
datasource:
db:
username: xxxx
password:
url: jdbc:mysql://localhost:3306/db
driver: com.mysql.jdbc.Driver
dbName: db
Bill .java:
package registration.audit.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.joda.time.DateTime;
import io.ebean.Model;
@Entity
@Table(name = "soap_user_billing")
public class Bill extends Model {
...
}
登录.java:
package registration.audit.model;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.joda.time.DateTime;
@Entity
@Table(name = "login")
public class Login {
....
}
登录.java:
package registration.service.audit;
public class AuditService {
public void insertLoginAuditDetails(Login loginAuditBean) throws Exception {
EbeanServer server = EbeanServerFactory.create(getDBServerConfig());
log.info("DB Server: {}, ", server.getName());
server.insert(loginAuditBean);
当数据库脱机时,EbeanServer会引发100%的与连接有关的错误,但是,即使日食日志显示以下内容,也会引发数据库打开“ Login bean not Enhanced error”的错误:
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.024 !MESSAGE ebean v11 +清单软件包-实体:[registration.audit.model]事务性:[] querybean:[registration.audit.model,registration.audit.model]
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.038 !MESSAGE ... ebean-enhance> cls:注册/审核/模型/票据msg:增强
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.053 !MESSAGE增强:注册/审核/模型/帐单
!ENTRY io.ebean.eclipse.enhancer 1 0 2019-06-26 10:44:49.059 !MESSAGE ... ebean-enhance> cls:注册/审核/模型/登录msg:增强
答案 0 :(得分:0)
我设法通过如下编辑mvn pom.xml文件来解决此问题:
<pluginManagement>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.12</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>org.avaje.tile:java-compile:1.1</tile>
<tile>io.ebean.tile:enhancement:11.38.1</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
以下,外部插件管理:
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.12</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>org.avaje.tile:java-compile:1.1</tile>
<tile>io.ebean.tile:enhancement:11.38.1</tile>
</tiles>
</configuration>
</plugin>
</plugins>
然后我运行了“ mvn clean install”并毫无问题地部署到了weblogic 12.2。