Guest User

Untitled

a guest
Mar 25th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. package mx.ebc.springboot
  2.  
  3. import org.springframework.boot.SpringApplication
  4. import org.springframework.boot.autoconfigure.SpringBootApplication
  5.  
  6. import org.springframework.boot.web.servlet.server.ServletWebServerFactory
  7. import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
  8. import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer
  9. import org.springframework.context.annotation.Bean
  10. import javax.sql.DataSource
  11.  
  12. import org.apache.tomcat.util.descriptor.web.ContextResource
  13. import org.apache.catalina.Context
  14.  
  15. @SpringBootApplication
  16. class SpringbootApplication {
  17.  
  18. static void main(String[] args) {
  19. SpringApplication.run SpringbootApplication, args
  20. }
  21.  
  22. @Bean
  23. ServletWebServerFactory servletContainer() {
  24. TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory()
  25. TomcatContextCustomizer customizer = { Context context ->
  26. ContextResource resource = new ContextResource()
  27. resource.setName("jdbc/myDataSource")
  28. resource.setType(DataSource.class.getName())
  29. resource.setAuth("Container")
  30. resource.setProperty("driverClassName", "oracle.jdbc.pool.OracleDataSource")
  31. resource.setProperty("url", "jdbc:oracle:thin:@10.10.10.10:1521:DEVL")
  32. resource.setProperty("username", "")
  33. resource.setProperty("password", "")
  34. context.getNamingResources().addResource(resource)
  35.  
  36. } as TomcatContextCustomizer
  37. tomcat.addContextCustomizers(customizer)
  38. tomcat
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment