2017-04-16 56 views
0

使用JHipster 4.2.0中的IntelliJ JPA的控制台不工作:JHipster和IntelliJ JPA控制台

javax.persistence.PersistenceException: [PersistenceUnit: Entities] Unable to build Hibernate SessionFactory 
java.lang.RuntimeException: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath. 

虽然在应用dev.yml的factory_class设置。

hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory 

有什么办法解决这个问题?

+0

这通常发生在您未将弹簧配置文件设置为dev时检查IJ设置 –

+0

我已经在Run/Debug Configurations和Maven Profiles中设置了spring dev配置文件,但不知道如何为jpa控制台设置它。 – dbConn

+0

JPA控制台是Ultimate Edition的一项功能,您是否询问过JetBrains支持?或者只是这个https://www.jetbrains.com/help/idea/2017.1/working-with-the-jpa-console.html#d469049e34 –

回答

0

我的解决办法是建立在资源文件夹这个persistence.xml文件,但是你需要修复,以满足您的需求,在我的情况我使用PostgreSQL的,但你可以用你的数据库类型配置:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="project name" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> 
     <!-- non-jta-datasource>jdbc/arquillian</non-jta-datasource --> 
     <properties> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/> 
      <property name="hibernate.cache.use_second_level_cache" value="true"/> 
      <property name="hibernate.cache.use_query_cache" value="false"/> 
      <property name="hibernate.show_sql" value="true"/> 
      <property name="hibernate.format_sql" value="true"/> 
      <property name="hibernate.use_sql_comments" value="false"/> 
      <property name="hibernate.generate_statistics" value="true"/> 
      <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/> 
      <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/dialysis-dev"/> 
      <property name="javax.persistence.jdbc.user" value="develop"/> 
      <property name="javax.persistence.jdbc.password" value="admpostgres"/> 
      <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/> 
      <property name="hibernate.ejb.naming_strategy" value="org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"/> 
      <property name="hibernate.ddl-auto" value="none"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

然后在视图菜单/ Tools Windows/Persistence中,您将能够看到这个持久性文件。因此,右键单击您可以看到JPA控制台。在我的情况下完美的作品。

使用这种方式,您不需要指定数据源,因为IntelliJ IDEA需要的所有配置都在上述文件中。顺便说一下,这在Intellij IDEA的Ultimate版本中进行了测试。