英文:
JSF classpath resolution
问题
我开始在一个包含不同包和不同war中重复的类和jsf名称的遗留jsf代码上工作。一个用于操作员,另一个用于客户。
我想知道这是否是偶然成功,还是类路径解析保证jsf文件将找到正确的后台bean。这两个bean都被命名为beans。
项目的结构如下:
- com.company.operator(war模块)
- com.company.operator.Back(类名)
- operator-module/src/main/webapp/operator/frontend1.xhtml(第一个jsf,引用${back.someFunction})
- com.company.customer(war模块)
- com.company.customer.Back(类名)
- customer-module/src/main/webapp/customer/frontend2.xhtml(第二个jsf,引用${back})
- com.company.ear(ear模块)
整个应用程序打包到同一个ear中。
是否可能在frontend2.xhtml中的引用${back}被解析为另一个模块中的com.company.operator.Back类?
IntelliJ找到了正确的引用。
英文:
I started to work on a legacy jsf code which contains duplicated class and jsf names in different packages and different wars, of course. One for the operators, the other for the customers.
I would like to know that it's working by accident or the classpath resolution guarantees that the jsf file will find the proper backing bean. Both beans are named beans.
The structure of the project looks like this:
- com.company.operator (war module)
- com.company.operator.Back (class name)
- operator-module/src/main/webapp/operator/frontend1.xhtml (first jsf which references ${back.someFunction})
- com.company.customer (war module)
- com.company.customer.Back (class name)
- customer-module/src/main/webapp/customer/frontend2.xhtml (2nd jsf referencing ${back}
- com.company.ear (ear module)
The whole application is packaged into the same ear.
Is it possible that the reference ${back} in frontend2.xhtml is resolved to com.company.operator.Back, the class in the other module?
IntelliJ founds the proper references.
答案1
得分: 1
每个WAR文件都由单独的类加载器加载,因此无法看到彼此。
https://blogs.oracle.com/javamagazine/post/how-the-jvm-locates-loads-and-runs-libraries
英文:
Every WAR file is loaded by separate classloader, thus cannot see each other.
https://blogs.oracle.com/javamagazine/post/how-the-jvm-locates-loads-and-runs-libraries
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论