我正在尝试让我的春季Kotlin项目中的Ebean工作,但是在运行应用程序时,我不断收到此异常:
Caused by: java.lang.IllegalStateException: Bean class com.sshmanager.server.database.entity.User is not enhanced?
at io.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:1556) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1423) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1333) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:748) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:369) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:197) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:124) ~[ebean-11.22.4.jar:na]
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:35) ~[ebean-11.22.4.jar:na]
at io.ebean.EbeanServerFactory.createInternal(EbeanServerFactory.java:109) ~[ebean-11.22.4.jar:na]
at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:70) ~[ebean-11.22.4.jar:na]
at com.sshmanager.server.database.EbeanFactoryBean.getObject(EbeanFactoryBean.kt:19) ~[classes/:na]
at com.sshmanager.server.database.EbeanFactoryBean.getObject(EbeanFactoryBean.kt:10) ~[classes/:na]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
... 36 common frames omitted
我已经添加了io.ebean.tile:enhancement
插件。
我也尝试使用mvn ebean:init
命令添加ebean.mf来控制增强,但是运行它时出现异常:
[INFO] Scanning for projects...
[INFO] --- tiles-maven-plugin: Injecting 1 tiles as intermediary parent artifacts for com.sshmanager:server...
[INFO] Mixed 'com.sshmanager:server:0.0.1-SNAPSHOT' with tile 'io.ebean.tile:enhancement:5.6' as its new parent.
[INFO] Mixed 'io.ebean.tile:enhancement:5.6' with original parent 'org.springframework.boot:spring-boot-starter-parent:2.0.4.RELEASE' as its new top level parent.
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- codegen-maven-plugin:4.2:init (default-cli) @ server ---
---------------------------------------------
EBEAN : INIT - interactive ebean initialiser
---------------------------------------------
Commands:
M - Manifest - add ebean.mf to control enhancement (recommended)
P - Test properties - Add test-ebean.properties to configure Ebean when running tests (recommended)
L - Logging - Add test logging entry to log SQL when running tests (recommended)
G - Generate migrations - Add GenerateDbMigration for generating DB migration scripts (recommended)
D - Docker - Add support for running tests against Docker containers (Postgres, ElasticSearch etc)
F - Finders - generate finders
T - Type safe query beans - manually generate them (rather than via APT/KAPT)
Q - Quit
Select an command: [M/P/L/G/D/F/T/Q] > M
Select a package that will contain the entity beans
0 - Other
1 - com.sshmanager.server.database.entity
select one of the options above
1
---- answer: com.sshmanager.server.database.entity
[ERROR] Error running detection on project
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring (String.java:1931)
at io.ebean.codegen.Detection.diff (Detection.java:186)
at io.ebean.codegen.Detection.getTopPackage (Detection.java:124)
at io.ebean.codegen.InteractionHelp.questionTransactionalPackage (InteractionHelp.java:44)
at io.ebean.codegen.DoAddManifest.run (DoAddManifest.java:21)
at io.ebean.codegen.Interaction.executeManifest (Interaction.java:123)
at io.ebean.codegen.Interaction.executeCommand (Interaction.java:48)
at io.ebean.codegen.Interaction.run (Interaction.java:36)
at io.ebean.codegen.InitMojo.execute (InitMojo.java:46)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.859 s
[INFO] Finished at: 2018-09-02T15:02:21+02:00
[INFO] Final Memory: 33M/206M
[INFO] ------------------------------------------------------------------------
除了这个例外,我找不到其他人...
有人知道我该如何解决吗?
我正在使用最新版本的Ebean。
编辑
我正在使用Intellij并刚刚安装了Ebean增强插件,但是它仍然无法正常工作。在构建消息中,我可以看到我的实体得到了增强,但是仍然有例外:
java.lang.IllegalStateException: Bean class com.sshmanager.server.database.entity.User is not enhanced?
答案 0 :(得分:1)
文档参考:https://ebean.io/docs/getting-started/maven
请注意,您需要 -增强磁贴(您拥有的) -src / main / resources / ebean.mf(看起来像您丢失的地方吗?)
请注意,mvn ebean:init
已过时,已被cli工具取代。
请参阅https://ebean.io/docs/getting-started/cli-tool
还请注意,有一个有关此问题的疑难解答页面:请参阅https://ebean.io/docs/trouble-shooting
答案 1 :(得分:0)
检查两件事 以下是pom中的内容
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>11.11.2</version>
<executions>
<execution>
<id>main</id>
<phase>process-classes</phase>
<configuration>
<transformArgs>debug=1</transformArgs>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
并且您的bean具有所有必需的注释,例如 @ Entity,@ Table和POJO扩展了io.ebean.Model
如果您操作不正确,还可以在下面的链接中进行检查 https://www.youtube.com/watch?v=o4kmglM48Vc