Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person {
- private static DatasourcesFraction datasourceWithMysql() {
- return new DatasourcesFraction()
- .jdbcDriver("com.mysql", (d) -> {
- d.driverClassName("com.mysql.jdbc.Driver");
- d.xaDatasourceClass("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
- d.driverModuleName("com.mysql");
- })
- .dataSource("PersonDS", (ds) -> {
- ds.driverName("com.mysql");
- ds.connectionUrl("jdbc:mysql://localhost:3306/person?useSSL=false");
- ds.userName("user");
- ds.password("pass");
- });
- }
- public static void main(String... args) throws Exception {
- Swarm container = new Swarm();
- container.fraction(datasourceWithMysql());
- container.fraction(new JPAFraction()
- .defaultDatasource("PersonDS"));
- JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "person.war");
- deployment.addAsWebInfResource(
- new ClassLoaderAsset("META-INF/persistence.xml", Person.class.getClassLoader()),
- "classes/META-INF/persistence.xml");
- deployment.addAllDependencies();
- container.start(deployment);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement