问题
i have this requirement to factor out the ebean models of a project so they can be reused by other play projects. i thought about creating a subproject containing only the models, but then that means i have to duplicate the subproject in every project that depends on it which isn't DRY enough to me. so then i created a jar of the subproject using publishLocal so the main project now just includes it like any other library in the build.sbt file. everything compiles well but when i run the main project i get this exception java.lang.IllegalStateException: Bean class module.models.User is not enhanced. how do i make sure the models in the jar are enhanced?
回答1:
Probably best to use compile time enhancement. For example, the maven enhancer.
Refer: http://ebean-orm.github.io/docs/setup/enhancement#maven
<plugin>
<groupId>org.avaje.ebeanorm</groupId>
<artifactId>avaje-ebeanorm-mavenenhancer</artifactId>
<version>4.8.1</version>
<executions>
<execution>
<id>main</id>
<phase>process-classes</phase>
<configuration>
<packages>org.example.domain.**,org.example.anotherdomain.**</packages>
<transformArgs>debug=1</transformArgs>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
来源:https://stackoverflow.com/questions/33891272/how-to-enhance-ebean-models-in-a-jar