我的 JBOSS 服务器(版本 7.1.1 Final)正在 Linux 服务器上运行。我的一个 Ear 应用程序是使用 jbosscli.sh 通过使用 jsch 连接到虚拟机来部署的。我的应用程序有一个包含实体 bean 的 ejb (3.0) 模块。如何在部署应用程序之前自动将数据源添加到在同一虚拟机上运行的 jboss 的standalone.xml。
最佳答案
这取决于您如何将部署发布到 JBOSS 服务器。我正在使用 APACHE ANT 构建将我的应用程序部署到 JBoss 服务器中。在 build.xml 中,我对其进行皮肤编辑,如下所示,它从属性文件中选择数据源所需的属性。
<!-- TX Data Source Settings -->
<replace file="${jboss.configuration}/standalone.xml" token="tx-connection-url>tx.datasource.connection.url" value="connection-url>${tx.datasource.connection.url}" />
<replace file="${jboss.configuration}/standalone.xml" token="tx-user-name>tx.datasource.username" value="user-name>${tx.datasource.username}" />
<replace file="${jboss.configuration}/standalone.xml" token="tx-password>tx.datasource.password" value="password>${tx.datasource.password}" />
<!--No TX Data Source Settings -->
<replace file="${jboss.configuration}/standalone.xml" token="no-tx-connection-url>no.tx.datasource.connection.url" value="connection-url>${no.tx.datasource.connection.url}" />
<replace file="${jboss.configuration}/standalone.xml" token="no-tx-user-name>no.tx.datasource.username" value="user-name>${no.tx.datasource.username}" />
<replace file="${jboss.configuration}/standalone.xml" token="no-tx-password>no.tx.datasource.password" value="password>${no.tx.datasource.password}" />
关于linux - 使用实体bean部署ear应用程序时,按照7.1.1自动将数据源添加到jboss中的standalone.xml中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22755259/