classpath 是每个 Spring 应用程序上下文还是每个 JVM?

huangapple go评论46阅读模式
英文:

Is classpath per spring application context or per JVM?

问题

现在,如果我要访问主Spring项目中的类路径,我是否应该期望属性冲突(即具有“name”=“abc”或“name”=“Xyz”),还是应该为每个项目获取单独的abc.properties文件(即SpringProject1和SpringProject2各一个)?

类路径是每个Spring上下文(spring-context)还是每个JVM上下文(JVM context)独立的?

英文:

Consider I have two Spring projects that have the same filename inside the classpath. For example:

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

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

Now, these projects are created as jar(s) and are added into third spring project, let's say the main-spring-project.

Now, if I want to access the classpath from the main-spring-project, shall I expect conflict in the properties(i.e having either "name"="abc" or "name"="Xyz") or shall I get separate abc.properties for each project(i.e one abc.properties for springProject1 and one for springProject2)

Is classpath is per spring-context or per JVM context?

答案1

得分: 1

Classpath 是 JVM 特定的。如果您在单个 JVM 上运行多个 Spring 实例,则它们将共享类路径。但是,如果它们在多个 JVM 上运行,则它们将有自己的类路径。

英文:

Classpath is JVM specific. If you have multiple Spring instances running on a single JVM, then they will all share the classpath. However if they are running on multiple JVMs, they will have their own classpaths

huangapple
  • 本文由 发表于 2020年7月29日 22:51:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63156370.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定