how to enhance ebean models in a jar

烈酒焚心 提交于 2019-12-11 20:04:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!