判断是否在jar包中运行

URL url = FactoryTestApplication.class.getResource("");
String protocol = url.getProtocol();
if ("jar".equals(protocol)) {
    HandlerProcessor.test = "jar包中启动";
} else if ("file".equals(protocol)) {
    HandlerProcessor.test = "本地运行启动";
}else{
    HandlerProcessor.test = "其他方式启动";
}

你可能感兴趣的:(Java,java,jar,spring,boot,maven,tomcat)