我在 pom.xml 中添加了 jdbc 驱动程序:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
我添加了 project-defaults.yml:
swarm:
datasources:
data-sources:
erp-ds:
driver-name: sqlserver
connection-url: jdbc:sqlserver://localhost:1433;DatabaseName=COMPARTILHADO
user-name: teste
password: teste
jdbc-drivers:
sqlserver:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
xa-datasource-name: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
driver-module-name: com.microsoft.sqlserver
但我运行应用程序会引发异常:
2017-06-14 13:09:54,337 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "erp-ds")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.sqlserver"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/erp-ds is missing [jboss.jdbc-driver.sqlserver]",
"org.wildfly.data-source.erp-ds is missing [jboss.jdbc-driver.sqlserver]"
]
}
在 Wildfly 中,我必须在standalone.xml 中添加驱动程序,但我不知道在 wildfly-swarm 中。在开发阶段,我用 jdbcDriver 添加了一个 DatasourcesFraction,这很容易,但是当我构建 .war 并运行 uberjar 时java -jar ??????-swarm.jar
会在上面抛出异常。