springboot项目启动加载外部jar

767 阅读1分钟

1. 用途:

可以不修改打包好的jar更新依赖,pom.xml里未写入的依赖也可以导入项目。

2.步骤:

1.修改pom.xml,项目打包后jar包不包含依赖

<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <includes>
                <include>
                    <groupId>nothing</groupId>
                    <artifactId>nothing</artifactId>
                </include>
            </includes>
            <mainClass>xxx.Application</mainClass>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>

2.执行命令启动

java -cp dataetlexcute-1.0-SNAPSHOT.jar -Dloader.path=C:\Users\lib -Dloader.main=xxx.Application org.springframework.boot.loader.PropertiesLauncher

3.参考:

stackoverflow.com/questions/3… soupport by Mihail Kostira

4.webkettle应用场景:

windows下kettle脚本需要和项目在一个盘。

\