Guest User

Untitled

a guest
Apr 30th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. package ProjetoRua.com.projetorua;
  2.  
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5.  
  6. @SpringBootApplication
  7. public class Application {
  8.  
  9.  
  10. public static void main(String[] args) {
  11. SpringApplication.run(Application.class, args);
  12.  
  13. }
  14. }
  15.  
  16. package ProjetoRua.com.projetorua;
  17. import org.springframework.context.annotation.Bean;
  18. import org.springframework.context.annotation.Configuration;
  19. import org.springframework.context.annotation.Profile;
  20. import org.springframework.jdbc.datasource.DriverManagerDataSource;
  21. import org.springframework.orm.jpa.JpaVendorAdapter;
  22. import org.springframework.orm.jpa.vendor.Database;
  23. import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  24.  
  25. import javax.sql.DataSource;
  26.  
  27. @Configuration
  28. @Profile("dev")
  29. public class DataConfiguration {
  30.  
  31. @Bean
  32. public DataSource dataSource(){
  33. DriverManagerDataSource dataSource = new DriverManagerDataSource();
  34. dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  35. dataSource.setUrl("jdbc:mysql://localhost:63342/projetorua");
  36. dataSource.setUsername("root");
  37. dataSource.setPassword("123456");
  38. return dataSource;
  39. }
  40.  
  41. @Bean
  42. public JpaVendorAdapter jpaVendorAdapter(){
  43. HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
  44. adapter.setDatabase(Database.MYSQL);
  45. adapter.setShowSql(true);
  46. adapter.setGenerateDdl(true);
  47. adapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect");
  48. adapter.setPrepareConnection(true);
  49. return adapter;
  50. }
  51. }
Add Comment
Please, Sign In to add comment