Spring Boot 动态加载jar文件
接口实现:
package org.bc.device;public interface IDeviceHandler {String start();String stop();
}
实现类:
package org.bc.device;
public class MqttDevice implements IDeviceHandler{
@Override
public String start() {
return “MqttDevice…start…”;
}
@Override
public String stop() {
return “MqttDevice…stop…”;
}
}
实现类:
package org.bc.device;public class HttpDevice implements IDeviceHandler{@Overridepublic String start() {return "HttpDevice..start...";}@Overridepublic String stop() {return "HttpDevice..stop...";}
}
打成jar:
device-mqtt-1.0-SNAPSHOT.jar
device-http-1.0-SNAPSHOT.jar
运行实例: