Java BlueMix在部署期间如何执行自动布线?
我下载了BlueMix Java SQLDB样板文件,我正在玩弄它,考虑扩展其他表,等等。我对在部署/运行时将BlueMix中的数据库服务链接到应用程序的“自动连接”感到有点困惑 在样板文件中,persistence.xml中有一些配置说明:Java BlueMix在部署期间如何执行自动布线?,java,boilerplate,websphere-liberty,ibm-cloud,Java,Boilerplate,Websphere Liberty,Ibm Cloud,我下载了BlueMix Java SQLDB样板文件,我正在玩弄它,考虑扩展其他表,等等。我对在部署/运行时将BlueMix中的数据库服务链接到应用程序的“自动连接”感到有点困惑 在样板文件中,persistence.xml中有一些配置说明: <persistence-unit name="openjpa-todo"> <!-- The cloudAutowiring-1.0 Liberty feature will resolve this to whatev
<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>
java:comp/env/jdbc/mydbdatasource
example.jpa.TODO
BlueMix/Liberty如何从部署的服务映射到jta数据源/持久化单元
自动布线是否需要满足任何条件或要求?它实际上非常酷。在应用程序部署期间,buildpack允许您执行一些额外的逻辑。Liberty buildpack中有一些逻辑可以自动连接两个服务。监控和分析、日志记录等等。节点构建包也可以做到这一点 我已经捕获了下面的一些自动布线
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Liberty Buildpack Version: v1.15-20150402-1422
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Retrieving IBM 7.1.2_sr2fp11ifx-20150312 JRE (ibm-java-jre-7.1-2.11-pxa6470_27sr2fp11ifx-20150312_01-sfj.tgz) ... (0.0s)
2015-04-10T15:24:52.82-0400 [STG] OUT Expanding JRE to .java ... (0.8s)
2015-04-10T15:24:52.82-0400 [STG] OUT -----> Retrieving App Management Agent 2015.03.09_101422 (com.ibm.ws.cloudoe.app-mgmt-proxy-agent.zip) ... (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT Expanding App Management to .app-management (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:53.74-0400 [STG] OUT Installing archive ... (0.8s)
2015-04-10T15:24:53.76-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty.ext-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:54.15-0400 [STG] OUT Installing archive ... (0.3s)
2015-04-10T15:24:54.33-0400 [STG] OUT -----> Retrieving and installing client jar(s) from com.ibm.ws.icap.clientJars.cloudant.zip (0.1s)
2015-04-10T15:24:54.34-0400 [STG] OUT -----> Auto-configuration is creating config for service instance 'Cloudant NoSQL DB-wr' of type 'cloudantNoSQLDB'
2015-04-10T15:24:54.36-0400 [STG] OUT -----> Liberty buildpack is done creating the droplet
2015-04-10T15:24:54.63-0400 [STG] ERR
2015-04-10T15:25:06.80-0400 [STG] OUT -----> Uploading droplet (147M)
BuildPack寻找的是绑定到应用程序的服务。如果存在诸如Cloudant或Monitoring and Analytics之类的绑定服务,它将添加正确的资源。对于Cloudant,由于它是JDBC,它将为您创建JDBC连接
此外,Liberty buildpack还为以下服务类型提供自动配置:SQL数据库ClearDB MySQL数据库MySQL ElephantSQL PostgreSQL Cloudant™ NoSQL数据库MongoLab dashDB数据缓存会话缓存MQ Light Monitoring and Analytics Auto Scaling Single Sign-On New Relic谢谢,我还在文档中找到了一些附加信息-它定义了一个完整的自动连接服务列表,如:Liberty buildpack为以下服务类型提供了自动配置:SQL数据库ClearDB MySQL数据库MySQL ElephantSQL PostgreSQL Cloudant™ NoSQL数据库Mongorab dashDB数据缓存会话缓存MQ Light Monitoring and Analytics Auto Scaling Single Sign-On New Relicaded指出,easierCloudant与JDBC不兼容,因此可以找到答案。它提供了一个利用RESTAPI的Java客户端库。答案应该得到纠正,因为认为cloudant可以通过JDBC/JPA配置为应用服务器的数据源是错误的。