Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public class Person {
  2. private static DatasourcesFraction datasourceWithMysql() {
  3. return new DatasourcesFraction()
  4. .jdbcDriver("com.mysql", (d) -> {
  5. d.driverClassName("com.mysql.jdbc.Driver");
  6. d.xaDatasourceClass("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
  7. d.driverModuleName("com.mysql");
  8. })
  9. .dataSource("PersonDS", (ds) -> {
  10. ds.driverName("com.mysql");
  11. ds.connectionUrl("jdbc:mysql://localhost:3306/person?useSSL=false");
  12. ds.userName("user");
  13. ds.password("pass");
  14. });
  15. }
  16.  
  17. public static void main(String... args) throws Exception {
  18. Swarm container = new Swarm();
  19. container.fraction(datasourceWithMysql());
  20. container.fraction(new JPAFraction()
  21. .defaultDatasource("PersonDS"));
  22. JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "person.war");
  23. deployment.addAsWebInfResource(
  24. new ClassLoaderAsset("META-INF/persistence.xml", Person.class.getClassLoader()),
  25. "classes/META-INF/persistence.xml");
  26. deployment.addAllDependencies();
  27. container.start(deployment);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement