刷新數據在pom.xml
我已經(從http://struberg.wordpress.com/2012/05/10/using-jpa-in-real-projects-part-1/拍攝):傳遞的JDBC URL到OpenJPA - Maven的插件PostgreSQL裏
<properties>
<openjpa.sql.action>refresh</openjpa.sql.action>
<database.driver.name>org.postgresql.Driver</database.driver.name>
<database.connection.url>jdbc:postgresql://myURL</database.connection.url>
<database.user>user</database.user>
<database.password>password</database.password>
</properties>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>${openjpa-version}</version>
<configuration>
<includes>**/entity/*.class</includes>
<excludes>**/entity/Q*.class</excludes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<sqlAction>${openjpa.sql.action}</sqlAction>
<connectionDriverName>${database.driver.name}</connectionDriverName>
<connectionProperties>
jdbcUrl=${database.connection.url},
user=${database.user},
password=${database.password},
</connectionProperties>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
<goal>sql</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>${openjpa-version}</version>
</dependency>
</dependencies>
</plugin>
出於某種原因,該網址是不正確過去了,我得到
目標執行增強器org.apache.openjpa:openjpa-maven-plugin:2.2.0:sql失敗:無法獲取驅動程序類「org.postgresql.Driver」和URL「null」的連接。您可能指定了無效的網址。 (org.apache.openjpa:OpenJPA中,Maven的插件:2.2.0:SQL:增強劑爲:工藝類)
我試過在connectionProperties
與url
更換jdbcUrl
,URL
等沒有什麼幫助。不過,我可以把網址中persistence.xml
這確實工作:
<property name="javax.persistence.jdbc.url"
value="jdbc:postgresql://myURL" />
驅動程序,用戶和密碼從Maven的性能得到。但是,由於此URL僅用於生成DDL(在運行時以不同方式創建數據源),因此我寧願在pom.xml
中也使用它,而不會污染persistence.xml
。有沒有辦法做到這一點?