Spring Boot Using Embedded Tomcat with JNDI

后端 未结 2 1584
无人及你
无人及你 2020-12-19 21:49

I am using Spring Boot with Embedded Tomcat and attempting to use JNDI but getting the following error:

javax.naming.NameNotFoundException: Name [jdbc/dataSource]

2条回答
  •  有刺的猬
    2020-12-19 22:24

    If you are using spring boot, no need for all of that class. It is already configured in @EnableAutoConfiguration or @SpringBootApplication

    Just put the following in your application.properties file or equivalent in application.yml file

    spring.datasource.driverClassName=JDBCDriverClassName
    spring.datasource.url=databaseUrl
    spring.datasource.username=databaseUsername
    spring.datasource.password=databasePassword
    spring.datasource.jndi-name=java:jdbc/dataSource
    

提交回复
热议问题