简体   繁体   English

将带有每个应用程序资源的子文件夹的外部根文件夹添加到tomcat(类路径)

[英]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...). 我在%TOMCAT_HOME%中为静态资源(* .xml,*。properties等)创建了文件夹资源

The deploy of my app (app1) create in %TOMCAT_HOME%/resources the folder app1-resources with the own files *.xml, *.properties... of my app1. 我的应用程序(app1)的部署在%TOMCAT_HOME%/ resource中创建,其文件夹app1-resources具有我的app1自己的文件* .xml,*。properties...。

In %TOMCAT_HOME%/conf/catalina.properties I added: 在%TOMCAT_HOME%/ conf / catalina.properties中,我添加了:

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: 应用1:

  • In java: classpath:app1-resources/config.xml 在Java中:classpath:app1-resources / config.xml
  • I create a folder for the resources of my app1: %TOMCAT_HOME%/resources/app1-resources/config.xml 我为app1的资源创建一个文件夹:%TOMCAT_HOME%/ resources / app1-resources / config.xml

App2: App2:

  • In java: classpath:app2-resources/config.xml 在Java中:classpath:app2-resources / config.xml
  • I create a folder for the resources of my app2: %TOMCAT_HOME%/resources/app2-resources/config.xml 我为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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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