[英]JNDI fails with javax.naming.NameNotFoundException:Name [jdbc/Database] is not bound in this Context when deploying Spring Boot2 Tomcat 9 NO EMBEDDED
When I tried to deploy an spring boot application from STS (eclipse) to a tomcat 9 container (embedded server was turn off excluded from pom) using JNDI it fails with the following message: 当我尝试使用JNDI将Spring Boot应用程序从STS(eclipse)部署到tomcat 9容器(嵌入式服务器已从pom中关闭)时,它失败并显示以下消息:
"javax.naming.NameNotFoundException: Name [jdbc/Database] is not bound in this Context. Unable to find [jdbc]." “ javax.naming.NameNotFoundException:名称[jdbc / Database]在此上下文中未绑定。无法找到[jdbc]。”
I have done a few things trying to solve it, but problem remains: 我已经做了一些尝试解决它的事情,但是问题仍然存在:
My application spring configure is: 我的应用程序春季配置是:
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
application.profiles("production");
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
builder.headless(false);
builder.profiles("production");
builder.web(WebApplicationType.NONE);
builder.run(args); }
And datasource config is: JNDI Datasource creation source code Image 数据源配置为: JNDI数据源创建源代码Image
I have tried other possible solutions (like creating context.xml in META-INF dir of app) but nothing works until now, same error is raised: Error Image 我尝试了其他可能的解决方案(例如,在应用程序的META-INF目录中创建context.xml),但到目前为止没有任何效果,并且会出现相同的错误: 错误图片
问题是eclipse STS中存在带有配置文件的第三名,并且位于我的环境中:.metadata.plugins \\ org.eclipse.wst.server.core \\ tmp0 \\ conf,我复制context.xml和server.xml配置,例如图像和问题已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.