| | |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.context.support.ClassPathXmlApplicationContext; |
| | | |
| | | import java.io.*; |
| | | import java.net.URL; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取ClassPath |
| | | * 获取ClassPath-jar |
| | | */ |
| | | public static String getClassPath() { |
| | | public static String getClassPathForJar() { |
| | | URL resource = ClassLoader.getSystemResource(""); |
| | | if (null == resource) { |
| | | return null; |
| | |
| | | |
| | | return decode(filter(resource.getPath())); |
| | | } |
| | | |
| | | /** |
| | | * 获取ClassPath-war |
| | | */ |
| | | public static String getClassPathForWar() throws IOException { |
| | | ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); |
| | | |
| | | return context.getResource("").getFile().getAbsolutePath(); |
| | | } |
| | | } |