2017-04-16 55 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版本中進行了測試。