打包插件
使用了三款
spring-boot-maven-plugin
maven-jar-plugin
maven-assembly-plugin(可用或不可用),用于打zip包
web打包插件
spring-boot-maven-plugin
maven-assembly-plugin

打包后生成的MANIFEST.MF文件
Manifest-Version: 1.0
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Implementation-Title: javaagent
Implementation-Version: 0.0.1-SNAPSHOT
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
Start-Class: com.example.javaagent.Javaagent
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 2.7.1
Created-By: Maven JAR Plugin 3.2.2
Main-Class: org.springframework.boot.loader.JarLauncher 
agent打包插件
拓展:
Premain-Class:包含premain方法的类,需要配置为类的全路径Can-Redefine-Classes:为true时表示能够重新定义classCan-Retransform-Classes:为true时表示能够重新转换class,实现字节码替换Can-Set-Native-Method-Prefix: 为true时表示能够设置native方法的前缀
maven-jar-plugin
maven-assembly-plugin

打包后生成的MANIFEST.MF文件
Manifest-Version: 1.0
Implementation-Title: agent
Premain-Class: com.example.agent.AgentApplication
Implementation-Version: 0.0.1-SNAPSHOT
Built-By: 2022055351
Can-Redefine-Classes: true
Implementation-Vendor-Id: com.example
Can-Retransform-Classes: true
Created-By: Apache Maven 3.8.6
Build-Jdk: 1.8.0_192
Implementation-URL: https://spring.io/projects/spring-boot/agent 
项目
web项目:agent-web
agent项目: agent
源码
https://www.aliyundrive.com/s/Tp3TZFsQBXo
点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。
agent项目

 
agent-web项目
 

流程
1.对agent项目进行打包,生成 agent-0.0.1-SNAPSHOT.jar,可能需要排除test生命周期

2.运行agent-web项目
方式1:
方式2:
对agent-web进行打包生成 agent-web-0.0.1-SNAPSHOT.jar,此时有
agent-web: agent-web-0.0.1-SNAPSHOT.jar
agent: agent-0.0.1-SNAPSHOT.jar
执行命令:
java -javaagent:D:\FILE\idea_project\agent\target\agent-0.0.1-SNAPSHOT.jar="123123" -jar javaagent-0.0.1-SNAPSHOT.jar 
效果




















