如果获取java应用的加载的classpath

时间:2022-02-14 23:42:32


String classpath = System.getProperty("java.class.path");

打印出来就可以了



//最初遇到的问题是,用junit做单元测试,,,,为什么会加载class-test下的资源呢?是插件干的事情还是 junit框架干掉事情呢?

网上找了很多文章,,,终于通过一句话解决问题

我在taxi-external下跑单元测试,,,,加载的classpath 居然是这样


D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-external\target\test-classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-external\target\classes
D:\apache-maven-3.1.0\repository\junit\junit\3.8.1\junit-3.8.1.jar
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-biz.user\target\test-classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-biz.user\target\classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-biz.common\target\test-classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-biz.common\target\classes
D:\apache-maven-3.1.0\repository\net\sf\json-lib\json-lib\2.4\json-lib-2.4-jdk15.jar
D:\apache-maven-3.1.0\repository\commons-beanutils\commons-beanutils\1.8.0\commons-beanutils-1.8.0.jar
D:\apache-maven-3.1.0\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar
D:\apache-maven-3.1.0\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar
D:\apache-maven-3.1.0\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar
D:\apache-maven-3.1.0\repository\net\sf\ezmorph\ezmorph\1.0.6\ezmorph-1.0.6.jar
D:\apache-maven-3.1.0\repository\com\ibm\icu\icu4j\4.8\icu4j-4.8.jar
D:\apache-maven-3.1.0\repository\org\apache\httpcomponents\fluent-hc\4.2.2\fluent-hc-4.2.2.jar
D:\apache-maven-3.1.0\repository\org\apache\httpcomponents\httpclient\4.2.2\httpclient-4.2.2.jar
D:\apache-maven-3.1.0\repository\org\apache\httpcomponents\httpcore\4.2.2\httpcore-4.2.2.jar
D:\apache-maven-3.1.0\repository\commons-codec\commons-codec\1.6\commons-codec-1.6.jar
D:\apache-maven-3.1.0\repository\org\apache\httpcomponents\httpmime\4.2.2\httpmime-4.2.2.jar
D:\apache-maven-3.1.0\repository\org\apache\httpcomponents\httpclient-cache\4.2.2\httpclient-cache-4.2.2.jar
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-framework\target\test-classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-framework\target\classes
D:\apache-maven-3.1.0\repository\org\mongodb\mongo-java-driver\2.10.1\mongo-java-driver-2.10.1.jar
D:\apache-maven-3.1.0\repository\com\kyo\ehcache_ee\2.6.6_unlicensed\ehcache_ee-2.6.6_unlicensed.jar
D:\apache-maven-3.1.0\repository\redis\clients\jedis\2.2.0\jedis-2.2.0.jar
D:\apache-maven-3.1.0\repository\commons-pool\commons-pool\1.5.5\commons-pool-1.5.5.jar
D:\apache-maven-3.1.0\repository\com\googlecode\xmemcached\xmemcached\1.4.1\xmemcached-1.4.1.jar
D:\apache-maven-3.1.0\repository\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar
D:\apache-maven-3.1.0\repository\c3p0\c3p0\0.9.1.2\c3p0-0.9.1.2.jar
D:\apache-maven-3.1.0\repository\org\mybatis\mybatis\3.2.2\mybatis-3.2.2.jar
D:\apache-maven-3.1.0\repository\org\mybatis\mybatis-spring\1.2.0\mybatis-spring-1.2.0.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-tx\3.1.0.RELEASE\spring-tx-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-aop\3.1.0.RELEASE\spring-aop-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-asm\3.1.0.RELEASE\spring-asm-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-beans\3.1.0.RELEASE\spring-beans-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-core\3.1.0.RELEASE\spring-core-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-context\3.1.0.RELEASE\spring-context-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-expression\3.1.0.RELEASE\spring-expression-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-jdbc\3.1.0.RELEASE\spring-jdbc-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\mysql\mysql-connector-java\5.1.25\mysql-connector-java-5.1.25.jar
D:\apache-maven-3.1.0\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.12\jackson-mapper-asl-1.9.12.jar
D:\apache-maven-3.1.0\repository\org\codehaus\jackson\jackson-core-asl\1.9.12\jackson-core-asl-1.9.12.jar
D:\apache-maven-3.1.0\repository\commons-httpclient\commons-httpclient\3.1\commons-httpclient-3.1.jar
D:\apache-maven-3.1.0\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar
D:\apache-maven-3.1.0\repository\org\slf4j\slf4j-log4j12\1.7.5\slf4j-log4j12-1.7.5.jar
D:\apache-maven-3.1.0\repository\com\kyo\servicelocator\1.2.1\servicelocator-1.2.1.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-context-support\3.1.0.RELEASE\spring-context-support-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\maven\dom4j\1.7-20060614\dom4j-1.7-20060614.jar
D:\apache-maven-3.1.0\repository\jaxme\jaxme-api\0.3\jaxme-api-0.3.jar
D:\apache-maven-3.1.0\repository\jaxen\jaxen\1.1-beta-8\jaxen-1.1-beta-8.jar
D:\apache-maven-3.1.0\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar
D:\apache-maven-3.1.0\repository\jdom\jdom\1.0\jdom-1.0.jar
D:\apache-maven-3.1.0\repository\xerces\xmlParserAPIs\2.6.2\xmlParserAPIs-2.6.2.jar
D:\apache-maven-3.1.0\repository\xerces\xercesImpl\2.6.2\xercesImpl-2.6.2.jar
D:\apache-maven-3.1.0\repository\xom\xom\1.0b3\xom-1.0b3.jar
D:\apache-maven-3.1.0\repository\com\ibm\icu\icu4j\2.6.1\icu4j-2.6.1.jar
D:\apache-maven-3.1.0\repository\xalan\xalan\2.6.0\xalan-2.6.0.jar
D:\apache-maven-3.1.0\repository\xml-apis\xml-apis\1.0.b2\xml-apis-1.0.b2.jar
D:\apache-maven-3.1.0\repository\org\ccil\cowan\tagsoup\tagsoup\0.9.7\tagsoup-0.9.7.jar
D:\apache-maven-3.1.0\repository\msv\xsdlib\20030807\xsdlib-20030807.jar
D:\apache-maven-3.1.0\repository\msv\relaxngDatatype\20030807\relaxngDatatype-20030807.jar
D:\apache-maven-3.1.0\repository\pull-parser\pull-parser\2.1.10\pull-parser-2.1.10.jar
D:\apache-maven-3.1.0\repository\xpp3\xpp3\1.1.3.3\xpp3-1.1.3.3.jar
D:\apache-maven-3.1.0\repository\stax\stax-api\1.0\stax-api-1.0.jar
D:\apache-maven-3.1.0\repository\junitperf\junitperf\1.8\junitperf-1.8.jar
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-bean\target\test-classes
D:\dev-branch\DB-20140428-W2\taxi-biz\taxi-bean\target\classes
D:\apache-maven-3.1.0\repository\com\google\guava\guava\14.0.1\guava-14.0.1.jar
D:\apache-maven-3.1.0\repository\com\kuaidadi\taxi-file\1.1\taxi-file-1.1.jar
D:\apache-maven-3.1.0\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar
D:\apache-maven-3.1.0\repository\asm\asm\3.3.1\asm-3.3.1.jar
D:\apache-maven-3.1.0\repository\com\alipay\alipay-sdk-java\DEV20140122103513\alipay-sdk-java-DEV20140122103513.jar
D:\apache-maven-3.1.0\repository\net\sourceforge\jexcelapi\jxl\2.6.10\jxl-2.6.10.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-frontend-jaxws\2.7.6\cxf-rt-frontend-jaxws-2.7.6.jar
D:\apache-maven-3.1.0\repository\xml-resolver\xml-resolver\1.2\xml-resolver-1.2.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-api\2.7.6\cxf-api-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\codehaus\woodstox\woodstox-core-asl\4.2.0\woodstox-core-asl-4.2.0.jar
D:\apache-maven-3.1.0\repository\org\codehaus\woodstox\stax2-api\3.1.1\stax2-api-3.1.1.jar
D:\apache-maven-3.1.0\repository\org\apache\ws\xmlschema\xmlschema-core\2.0.3\xmlschema-core-2.0.3.jar
D:\apache-maven-3.1.0\repository\org\apache\geronimo\specs\geronimo-javamail_1.4_spec\1.7.1\geronimo-javamail_1.4_spec-1.7.1.jar
D:\apache-maven-3.1.0\repository\wsdl4j\wsdl4j\1.6.3\wsdl4j-1.6.3.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-core\2.7.6\cxf-rt-core-2.7.6.jar
D:\apache-maven-3.1.0\repository\com\sun\xml\bind\jaxb-impl\2.2.6\jaxb-impl-2.2.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-bindings-soap\2.7.6\cxf-rt-bindings-soap-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-databinding-jaxb\2.7.6\cxf-rt-databinding-jaxb-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-bindings-xml\2.7.6\cxf-rt-bindings-xml-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-frontend-simple\2.7.6\cxf-rt-frontend-simple-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-transports-http\2.7.6\cxf-rt-transports-http-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-ws-addr\2.7.6\cxf-rt-ws-addr-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-ws-policy\2.7.6\cxf-rt-ws-policy-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\apache\neethi\neethi\3.0.2\neethi-3.0.2.jar
D:\apache-maven-3.1.0\repository\org\apache\cxf\cxf-rt-transports-http-jetty\2.7.6\cxf-rt-transports-http-jetty-2.7.6.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-server\8.1.7.v20120910\jetty-server-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-continuation\8.1.7.v20120910\jetty-continuation-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-http\8.1.7.v20120910\jetty-http-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-io\8.1.7.v20120910\jetty-io-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-util\8.1.7.v20120910\jetty-util-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\eclipse\jetty\jetty-security\8.1.7.v20120910\jetty-security-8.1.7.v20120910.jar
D:\apache-maven-3.1.0\repository\org\apache\geronimo\specs\geronimo-servlet_3.0_spec\1.0\geronimo-servlet_3.0_spec-1.0.jar
D:\apache-maven-3.1.0\repository\org\springframework\spring-web\3.1.0.RELEASE\spring-web-3.1.0.RELEASE.jar
D:\apache-maven-3.1.0\repository\org\apache\velocity\velocity\1.7\velocity-1.7.jar
/D:/eclipse/configuration/org.eclipse.osgi/bundles/357/1/.cp/