在java工程中的配置文件中,有时需要使用classpath来配置xml等:
<!--JAR启动-->
<import resource="classpath:META-INF/ams_web_applicationContext-server.xml"/>
<!--EJB启动
<import resource="classpath:generated/ams_common_svr_applicationContext-bean-ejbclient.xml"/>
<import resource="classpath:generated/ams_core_applicationContext-bean-ejbclient.xml"/>
<import resource="classpath:generated/ams_applicationContext-bean-ejbclient.xml"/>
<import resource="classpath:generated/acct_core_business_applicationContext-bean-ejbclient.xml"/>
<import resource="classpath:generated/acct_common_svr_applicationContext-bean-ejbclient.xml"/>
<import resource="classpath:generated/ams_web_applicationContext-ejb-reserved.xml"/>
-->
<!--依赖web包-->
<import resource="classpath:META-INF/ams_web_applicationContext-action.xml"/>
<import resource="classpath:META-INF/acct_common_web-business.xml"/>
<import resource="classpath:META-INF/acct_common_web-cache.xml"/>
classpath配置在工程根目录的.classpath文件中,可以直接文本方式打开:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/aopalliance-1.0.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/aspectjweaver-1.6.9.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-dbcp.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-dbutils-1.5.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-dbutils-1.5-src.zip"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/commons-pool-1.6.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/jasper-compiler.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/jasper-runtime.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/jstl.jar"/>
<classpathentry kind="lib" path="D:/Ailk/Jworkspace/summer/WebRoot/WEB-INF/lib/log4j.jar"/>
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>
JVM加载类时,使用classpath的策略是从前到后搜索,如果在搜索过程中,已经找到需要加载的类,那么就不再向后搜索。所以,如果在classpath中存在重复的类,那么JVM只加载classpath配置中,位置靠前的类。后面的类就不会被加载了