【发布时间】:2015-04-10 19:18:38
【问题描述】:
我下载了 BlueMix Java SQLDB Boilerplate,我正在使用它,查看扩展其他表等。我对将 BlueMix 中的数据库服务链接到应用程序的“自动装配”有点困惑部署/运行时。
在样板文件中,persistence.xml 中有一些配置:
<persistence-unit name="openjpa-todo">
<!-- The cloudAutowiring-1.0 Liberty feature will resolve this to whatever
the database service name is -->
<!-- When running locally without this feature, create a datasource with
the JNDI name "jdbc/mydbdatasource" in server.xml -->
<!-- If using MySQL locally then use the "url" property and append "?relaxAutoCommit=true", for example:
<dataSource id='mysql-datasource' jdbcDriverRef='mysql-driver' jndiName='jdbc/mydbdatasource'>
<properties user='root' password='password' url="jdbc:mysql://localhost:3306/db?relaxAutoCommit=true"/>
</dataSource> -->
<jta-data-source>java:comp/env/jdbc/mydbdatasource</jta-data-source>
<class>example.jpa.TODO</class>
<properties>
<!-- allow table definitions/creation on-the-fly jpa-2.0 feature -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
<!-- allow table definitions/creation on-the-fly jpa-2.1 feature -->
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
BlueMix/Liberty 如何从部署的服务映射到 jta-data-source/persistence-unit?
是否需要满足任何条件或要求才能进行自动装配?
【问题讨论】:
标签: java boilerplate websphere-liberty ibm-cloud