简体   繁体   English

类路径是每个 spring 应用程序上下文还是每个 JVM?

[英]Is classpath per spring application context or per JVM?

Consider I have two Spring projects that have the same filename inside the classpath.考虑我有两个 Spring 项目,它们在类路径中具有相同的文件名。 For example:例如:

SpringProject-1: @PropertySource(value = "classpath:database/abc.properties") and abc.properties has "name"="abc" SpringProject-1:@PropertySource(value = "classpath:database/abc.properties") 和 abc.properties 有 "name"="abc"

SpringProject-2: @PropertySource(value = "classpath:database/abc.properties") and abc.properties has "name"="Xyz" SpringProject-2:@PropertySource(value = "classpath:database/abc.properties") 和 abc.properties 有 "name"="Xyz"

Now, these projects are created as jar(s) and are added into third spring project, let's say the main-spring-project.现在,这些项目被创建为 jar(s) 并被添加到第三个 spring 项目中,比如说 main-spring-project。

Now, if I want to access the classpath from the main-spring-project, shall I expect conflict in the properties(ie having either "name"="abc" or "name"="Xyz") or shall I get separate abc.properties for each project(ie one abc.properties for springProject1 and one for springProject2)现在,如果我想从 main-spring-project 访问类路径,我应该期望属性冲突(即具有“name”=“abc”或“name”=“Xyz”)还是应该获得单独的 abc每个项目的 .properties(即一个用于 springProject1 的 abc.properties 和一个用于 springProject2 的)

Is classpath is per spring-context or per JVM context?类路径是每个弹簧上下文还是每个 JVM 上下文?

Classpath is JVM specific.类路径是 JVM 特定的。 If you have multiple Spring instances running on a single JVM, then they will all share the classpath.如果您有多个 Spring 实例在单个 JVM 上运行,那么它们都将共享类路径。 However if they are running on multiple JVMs, they will have their own classpaths但是,如果它们在多个 JVM 上运行,它们将有自己的类路径

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

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