2016-06-24 7 views
0

Ich versuche und nicht zu spielen, spielen 2.5.Play Framework kann nicht lesen db config und injizieren JPAApi

Mein Controller:

public class HomeController extends Controller { 

    private JPAApi db; 

    @Inject 
    public HomeController(JPAApi api) { 
     this.db = api; 
    } 

    public Result index(String name) { 
     return ok(views.html.index.render("hello", name, Collections.singletonList("world"))); 
    } 
} 

Meine conf \ META-INF \ persistence.xml

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" 
      version="2.1"> 
    <persistence-unit name="readwritePU" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> 
    <non-jta-data-source>ReadWriteDS</non-jta-data-source> 

    <properties> 
     <property name="hibernate.connection.isolation" value="1" /> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL94Dialect" /> 
     <property name="hibernate.cache.use_second_level_cache" value="false" /> 
     <property name="hibernate.cache.use_query_cache" value="false" /> 
    </properties> 
    </persistence-unit> 
</persistence> 

Meine conf \ application.conf

jpa.default=readwritePU 

db { 
    #pool = "hikaricp" 

    default.driver = org.postgresql.Driver 
    default.url = "jdbc:postgresql://127.0.0.1:5432/mydbname" 
    default.username = "postgres" 
    default.password = "123456" 
    #default = "default" 

    default.jndiName=ReadWriteDS 
} 

Der Fehler mit und ohne Pool Konfigurationsschlüssel aktiviert in application.conf oben:

No configuration setting found for key 'pool' 
Error in custom provider, com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'pool' 
    while locating play.api.db.DBApiProvider 
    while locating play.api.db.DBApi 
    for field at play.api.db.NamedDatabaseProvider.dbApi(DBModule.scala:80) 
    while locating play.api.db.NamedDatabaseProvider 
    at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) 
    at play.api.db.DBModule$$anonfun$namedDatabaseBindings$1.apply(DBModule.scala:34): 
Binding(interface play.api.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget([email protected])) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) 
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'pool' 

    pool has type STRING rather than OBJECT 
Error in custom provider, com.typesafe.config.ConfigException$WrongType: application.conf @ file:/E:/workspace2/coup/target/scala-2.11/classes/application.conf: 344: pool has type STRING rather than OBJECT 
    while locating play.api.db.DBApiProvider 
    while locating play.api.db.DBApi 
    for parameter 0 at play.db.DefaultDBApi.<init>(DefaultDBApi.java:27) 
    at play.db.DefaultDBApi.class(DefaultDBApi.java:27) 
    while locating play.db.DefaultDBApi 
    while locating play.db.DBApi 
    for field at play.db.DBModule$NamedDatabaseProvider.dbApi(DBModule.java:61) 
    while locating play.db.DBModule$NamedDatabaseProvider 
    at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) 
    at play.db.DBModule.bindings(DBModule.java:40): 
Binding(interface play.db.Database qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to ProviderTarget([email protected])) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1) 
Caused by: com.typesafe.config.ConfigException$WrongType: application.conf @ file:/E:/workspace2/coup/target/scala-2.11/classes/application.conf: 344: pool has type STRING rather than OBJECT 

Ich habe so viele verschiedene Optionen und Kombinationen ausprobiert, ich habe keine Ideen mehr. Google kennt die Fehler nicht einmal. Play hört einfach auf zu arbeiten und ich muss es neu starten. Versuchen

Antwort

1

jpa.default=readwritePU 

db { 
    default { 
     hikaricp { 
      dataSourceClassName=org.postgresql.ds.PGSimpleDataSource 
      dataSource { 
       serverName = localhost 
       databaseName = "mydbname" 
       user = "postgres" 
       password = "123456" 
      } 
     } 
     jndiName=ReadWriteDS 
    } 
} 
Verwandte Themen