方式一、
Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath:/xzhconfigs/"); String path = resources[0].getURL().getPath(); System.out.println("-------" + path);
=======控制台输出
-------/Users/**/Documents/namquan-customer/target/classes/xzhconfigs/
方式二、
URL classPath = XZHConfig.class.getClassLoader().getResource(""); String xzhConfigPath = classPath.getPath() + "xzhconfigs/" ; System.out.println(xzhConfigPath);
======控制台输出
/Users/**/Documents/namquan-customer/target/classes/xzhconfigs/