今天遇到问题:html
在作openjpa开发时,运行jsp文件出现以下错误:<openjpa-2.4.1-r422266:1730418 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "java
程序在java测试时openjpa没问题,用jsp调用出现如上错误apache
查网上找到一解决办法,连接为:http://rockyfeng.me/jpa_entity.htmldom
出现下列错误 Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: " com.example.jpastudy.Message". 解决方法1, 在persistence.xml中添加 <property name="openjpa.RuntimeUnenhancedClasses" value="supported" /> 但不提倡这么作,这样会致使openjpa在运行时对entity类进行加强而致使性能降低。 咱们应该用编译时的加强。 解决方法2, 在pom.xml中加入如下代码 <build> <plugins> <plugin> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-maven-plugin</artifactId> <version>2.2.0</version> <configuration> <includes>**/domain/*.class</includes> <excludes>**/domain/XML*.class</excludes> <addDefaultConstructor>true</addDefaultConstructor> <enforcePropertyRestrictions>true</enforcePropertyRestrictions> </configuration> <executions> <execution> <id>enhancer</id> <phase>process-classes</phase> <goals> <goal>enhance</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa</artifactId> <!-- set the version to be the same as the level in your runtime --> <version>2.2.0</version> </dependency> </dependencies> </plugin> </plugins> </build> 并在persitence.xml中加入 <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" /> <property name="openjpa.DynamicEnhancementAgent" value="false" /> 运行mvn 以前都运行一下 mvn openjpa:enhance