Tutorial of using ebean

Posted by rheroux on Sat, 02 Nov 2019 22:07:18 +0100

Since 2018, we have been accumulating server related technologies. In the company, from a client programmer, he actively requests to do server tasks, hoping to take the opportunity to improve his application ability of server technology. In private, we have been studying the related technologies of vert.x. however, the company uses php + yii solution. We can only calm down and absorb some advantages of the company's solutions. For example, yii's "Query Builder" is very efficient and convenient Looking through all kinds of materials, I found ebean. Most of the domestic documents boast that it is efficient, and there is not an entry-level tutorial. This article is some of the author's experience. Share here, hope to help you learn ebean.

Introduction to the environment used

idea + gradle + kotlin

The ebean plug-in installation of idea (what must be done)

Installation method:

  • Open idea, file > Settings > plugins > ebean 11 to install the plug-in, as shown in the figure:

  • Open the bean adding tool, and make sure there is a small tick in front of "Ebean XXXX" under build, as shown in the figure:

Note: if you don't do this, an exception of "io. Ebean. Config. Beannotenforcedexception" will be thrown when running.

Exception in thread "main" io.ebean.config.BeanNotEnhancedException: Bean class org.example.domain.channel_statistics_ret is not enhanced? Check packages specified in ebean.mf. If you are running in IDEA or Eclipse check that the enhancement plugin is installed. See https://ebean.io/docs/trouble-shooting#not-enhanced
	at io.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:1581)
	at io.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1446)
	at io.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1355)
	at io.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:770)
	at io.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:374)
	at io.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:197)
	at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:124)
	at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:35)
	at io.ebean.EbeanServerFactory.createInternal(EbeanServerFactory.java:109)
	at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:70)
	at MainKt.main(main.kt:26)
	at MainKt.main(main.kt)

Topics: Java PHP Gradle Eclipse