Spring boot 如何在SpringBoot应用程序中定义资源,相当于<;资源参考>;在传统的web.xml中?

Spring boot 如何在SpringBoot应用程序中定义资源,相当于<;资源参考>;在传统的web.xml中?,spring-boot,jndi,servlet-3.0,Spring Boot,Jndi,Servlet 3.0,我正在做一个项目,它是使用SpringBoot 1.4.3-RELEASE开发的 根据公司内部文档,它要求我们在WEB-INF/WEB.xml中为每个应用程序定义一个。示例如下: <resource-ref> <res-ref-name>connectivityConfiguration</res-ref-name> <res-type>com.hide-my-company-name.ConnectivityConfigurati

我正在做一个项目,它是使用SpringBoot 1.4.3-RELEASE开发的

根据公司内部文档,它要求我们在WEB-INF/WEB.xml中为每个应用程序定义一个。示例如下:

<resource-ref>
    <res-ref-name>connectivityConfiguration</res-ref-name>
    <res-type>com.hide-my-company-name.ConnectivityConfiguration</res-type>
</resource-ref>

连接配置
com.hide-my-company-name.ConnectivityConfiguration
然后使用JNDI查找来获取某个对象。但是我没有WEB-INF/WEB.xml

因此,我在本地tomcat context.xml中定义资源,而不是WEB-INF/WEB.xml

<Context>
    <Resource name="connectivityConfiguration" 
              type="com.hide-my-company-name.ConnectivityConfiguration" />
</Context>

它起作用了。然而,只有在我当地的发展环境中。 因为我无法在部署后更改“context.xml”或“server.xml”

问题: 是否有其他方法可以使用SpringBoot定义相同的资源?例如,通过。Java代码,还是通过application.properties

@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(WebApplication.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(WebApplication.class, args);
    }

    @Bean
    public TomcatEmbeddedServletContainerFactory tomcatFactory() {
        return new TomcatEmbeddedServletContainerFactory() {

            @Override
            protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
                tomcat.enableNaming();
                return super.getTomcatEmbeddedServletContainer(tomcat);
            }

            @Override
            protected void postProcessContext(Context context) {
                ContextResource resource = new ContextResource();
                resource.setName("connectivityConfiguration");
                resource.setType("com.hide-my-company-name.ConnectivityConfiguration");
                context.getNamingResources().addResource(resource);
            }
        };

}
}