英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论