Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mx.ebc.springboot
- import org.springframework.boot.SpringApplication
- import org.springframework.boot.autoconfigure.SpringBootApplication
- import org.springframework.boot.web.servlet.server.ServletWebServerFactory
- import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
- import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer
- import org.springframework.context.annotation.Bean
- import javax.sql.DataSource
- import org.apache.tomcat.util.descriptor.web.ContextResource
- import org.apache.catalina.Context
- @SpringBootApplication
- class SpringbootApplication {
- static void main(String[] args) {
- SpringApplication.run SpringbootApplication, args
- }
- @Bean
- ServletWebServerFactory servletContainer() {
- TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory()
- TomcatContextCustomizer customizer = { Context context ->
- ContextResource resource = new ContextResource()
- resource.setName("jdbc/myDataSource")
- resource.setType(DataSource.class.getName())
- resource.setAuth("Container")
- resource.setProperty("driverClassName", "oracle.jdbc.pool.OracleDataSource")
- resource.setProperty("url", "jdbc:oracle:thin:@10.10.10.10:1521:DEVL")
- resource.setProperty("username", "")
- resource.setProperty("password", "")
- context.getNamingResources().addResource(resource)
- } as TomcatContextCustomizer
- tomcat.addContextCustomizers(customizer)
- tomcat
- }
- }
Add Comment
Please, Sign In to add comment