wildfly-swarm jpa / dadatasources yaml.xml [英] wildfly-swarm jpa/dadatasources yaml.xml
问题描述
yaml.xml:
数据源:
jdbc驱动程序:
com.mysql:
驱动程序名称:com.mysql.jdbc.Driver
xa- datasource-class-name:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
driver-module-name:com.mysql
data-sources:
PicketlinkDS:
driver-name:com.mysql
connection-url:jdbc:mysql:// localhost:3306 / testjpa
用户名:root
密码:javacom2
jta: true
use-java-context:true
min-pool-size:8
max-pool-size:20
pool-prefill:true
connection-checke r-class-name:org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
background-validation:true
exception-sorter-class-name:org.jboss.jca.adapters。 jdbc.extensions.mysql.MySQLExceptionSorter
连接属性:CharacterEncoding / UTF-8 UseUnicode / true
persistence.xml:
< persistence-unit name =picketlinktransaction-type =JTA>
< jta-data-source> java:jboss / datasources / PicketlinkDS
< / jta-data-source>
<! - 声明是否扫描jar文件中标注了@Enity类加入到上下文若不扫描,则如下:(可选) - >
< exclude-unlisted-classes> false< / exclude-unlisted-classes>
< properties>
< property name =hibernate.dialectvalue =org.hibernate.dialect.MySQLDialect/>
< property name =hibernate.query.substitutionsvalue =true = 1,false = 0/>
< property name =hibernate.dialect.storage_enginet
value =innodb/>
<! - JBoss / Wildfly JTA事务 - >
< property name =hibernate.transaction.jta.platform
value =org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform/>
< property name =hibernate.cache.use_query_cachevalue =false/>
< property name =hibernate.cache.use_second_level_cache
value =false/>
< property name =hibernate.show_sqlvalue =true/>
< property name =hibernate.format_sqlvalue =false/>
< property name =hibernate.hbm2ddl.autovalue =create-drop/>
< property name =hibernate.hbm2ddl.import_filesvalue =initial_data.sql/>
< property name =hibernate.jdbc.batch_sizevalue =1000/>
< property name =hibernate.order_insertsvalue =true/>
< property name =hibernate.order_updatesvalue =true/>
< property name =hibernate.connection.characterEncoding
value =UTF-8/>
< property name =hibernate.current_session_context_class
value =jta/>
< property name =wildfly.jpa.default-unitvalue =true/>
< / properties>
< / persistence-unit>
主类:
class $ {code> ClassLoader cl = Main.class.getClassLoader();
URL stageConfig = cl.getResource(project-development.yml);
Swarm swarm = new Swarm()。withConfig(stageConfig);
//创建一个或多个部署
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addAsWebInfResource(new ClassLoaderAsset(META-INF / persistence.xml,Main.class.getClassLoader()),classes / META-INF / persistence.xml);
//将资源添加到部署
//deployment.addClass(PmsPersonService.class);
deployment.addClass(Person.class);
// deployment.addClass(EntityManagerProvider.class);
deployment.addAsWebInfResource(new ClassLoaderAsset(META-INF / load.sql,Main.class.getClassLoader()),classes / META-INF / load.sql);
deployment.addResource(RestApplication.class);
deployment.addResource(HelloWorldEndpoint.class);
deployment.addAllDependencies();
swarm.start();
swarm.deploy(deployment);
异常:
WFLYCTL0412:未安装的必需服务:=>jboss想法,运行如何处理这个异常?
非常焦虑!!!!!!!!
首先,我建议删除自定义主( )因为没有什么具体的,你在那里做的是无法实现的,而不是用Maven war
包装。
,我认为你的yaml缺少 swarm:
作为第一级,你也可以删除JDBC驱动程序创建,让WF Swarm为你做。因此,我将驱动程序名称
切换到 mysql
,只要MySQL的JDBC驱动程序依赖关系项目的一部分。
swarm:
数据源:
数据源:
PicketlinkDS :
driver-name:mysql
connection-url:jdbc:mysql:// localhost:3306 / testjpa
用户名:root
密码:javacom2
jta :true
use-java-context:true
min-pool-size:8
max-pool-size:20
pool-prefill:true
connection- checker-class-name:org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
background-validation:true
exception-sorter-class-name:org.jboss.jca.adapters。 jdbc.extensions.mysql.MySQLExceptionSorter
连接属性:CharacterEncoding / UTF-8 UseUnicode / true
I have a question.I am integrating EJB, JAX-RS, CDI, JPA, and data sources. When I integrate these into wildfly-swarm, there are some problems that can not work properly.
yaml.xml:
datasources:
jdbc-drivers:
com.mysql:
driver-class-name: com.mysql.jdbc.Driver
xa-datasource-class-name: com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
driver-module-name: com.mysql
data-sources:
PicketlinkDS:
driver-name: com.mysql
connection-url: jdbc:mysql://localhost:3306/testjpa
user-name: root
password: javacom2
jta : true
use-java-context: true
min-pool-size : 8
max-pool-size : 20
pool-prefill : true
connection-checker-class-name : org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
background-validation : true
exception-sorter-class-name : org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter
connection-properties : CharacterEncoding/ UTF-8 UseUnicode/true
persistence.xml:
<persistence-unit name="picketlink" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/PicketlinkDS
</jta-data-source>
<!-- 声明是否扫描jar文件中标注了@Enity类加入到上下文.若不扫描,则如下:(可选) -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.query.substitutions" value="true=1, false=0" />
<property name="hibernate.dialect.storage_enginet"
value="innodb" />
<!-- JBoss/Wildfly JTA Transaction -->
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.cache.use_second_level_cache"
value="false" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.hbm2ddl.import_files" value="initial_data.sql" />
<property name="hibernate.jdbc.batch_size" value="1000" />
<property name="hibernate.order_inserts" value="true" />
<property name="hibernate.order_updates" value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<property name="hibernate.current_session_context_class"
value="jta" />
<property name="wildfly.jpa.default-unit" value="true" />
</properties>
</persistence-unit>
main Class:
ClassLoader cl = Main.class.getClassLoader();
URL stageConfig = cl.getResource("project-development.yml");
Swarm swarm = new Swarm().withConfig(stageConfig);
// Create one or more deployments
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", Main.class.getClassLoader()), "classes/META-INF/persistence.xml");
// Add resource to deployment
//deployment.addClass(PmsPersonService.class);
deployment.addClass(Person.class);
// deployment.addClass(EntityManagerProvider.class);
deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/load.sql", Main.class.getClassLoader()), "classes/META-INF/load.sql");
deployment.addResource(RestApplication.class);
deployment.addResource(HelloWorldEndpoint.class);
deployment.addAllDependencies();
swarm.start();
swarm.deploy(deployment);
exception: "WFLYCTL0412: Required services that are not installed:" =>"jboss.naming.context.java.jboss.datasources.PicketlinkDS"],
idea ,Run on how to deal with this exception? Very anxious!!!!!!!!
First off I'd suggest removing the custom main() as there's nothing specific you're doing there that can't be achieved with Maven war
packaging.
Secondly, I think your yaml is missing the swarm:
as the first level, and you can also remove the JDBC Driver creation and let WF Swarm do that for you. For that I switched the driver-name
to mysql
, which will work so long as the JDBC driver dependency for MySQL is part of the project.
swarm:
datasources:
data-sources:
PicketlinkDS:
driver-name: mysql
connection-url: jdbc:mysql://localhost:3306/testjpa
user-name: root
password: javacom2
jta: true
use-java-context: true
min-pool-size: 8
max-pool-size: 20
pool-prefill: true
connection-checker-class-name: org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
background-validation: true
exception-sorter-class-name: org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter
connection-properties: CharacterEncoding/ UTF-8 UseUnicode/true
这篇关于wildfly-swarm jpa / dadatasources yaml.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!