简体   繁体   中英

Add external root folder with subfolders for resources for each app to tomcat (classpath)

I created folder resources in %TOMCAT_HOME% for static resources (*.xml, *.properties, etc...).

The deploy of my app (app1) create in %TOMCAT_HOME%/resources the folder app1-resources with the own files *.xml, *.properties... of my app1.

In %TOMCAT_HOME%/conf/catalina.properties I added:

shared.loader=${catalina.base}/resources

But when I access to any file with the classpath:

(...)
<value>classpath:app1-resources/conf.properties</value>
(...)

Or:

(...)
@ImportResource("classpath:app1-resources/spring-config.xml")
(...)

It fail!!! Because not found resources...

If I change the configuration to:

shared.loader=${catalina.base}/resources/app1-resources

And change the access to those to:

(...)
<value>classpath:conf.properties</value>
(...)

Or:

(...)
@ImportResource("classpath:spring-config.xml")
(...)

It works.

My problem is if I deploy more than one app in the same tomcat, I want to access to the resources of each app independently. For example:

App1:

  • In java: classpath:app1-resources/config.xml
  • I create a folder for the resources of my app1: %TOMCAT_HOME%/resources/app1-resources/config.xml

App2:

  • In java: classpath:app2-resources/config.xml
  • I create a folder for the resources of my app2: %TOMCAT_HOME%/resources/app2-resources/config.xml

My question is: Can I specify a root directory which my resources lies underneath it (in a custom folder for each app)?

Anybody can solve my problem?

Thanks in advance.

在指定它shared.loadercommon.loader财产/conf/catalina.properties

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM