How to define a resource in a SpringBoot application, which is equivalent to <resource-ref> in traditional web.xml?

I am working on a project that is developed using SpringBoot 1.4.3-RELEASE.

According to the internal document of the company, we need to define a in WEB-INF / web.xml for each application. Example below:

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

And then use the JNDI lookup to get a specific object. But I do not have WEB-INF / web.xml.

So, instead of WEB-INF / web.xml, I define the resource in the local tomcat context.xml.

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

It works. However, only in my local development environment. Because after deployment, I cannot change "context.xml" or "server.xml".

Question: Is there a different approach for defining the same resource using SpringBoot? For instance. via. Java code or through application.properties?

+4

Source: https://habr.com/ru/post/1675509/


All Articles