problem description
1. We intend to add some bytecodes for monitoring before the actual operation, such as slow sql
, dubbo concurrency
, development release time to check mybatis/ibatis configuration files
the environmental background of the problems and what methods you have tried
2. We use Instrumentation
to import the Agent jar
package that we monitor and develop at startup, but we find that the following code using javassist
doesn"t work
<modelVersion>4.0.0</modelVersion>
<groupId>top.huzhurong.agent</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.1-GA</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Premain-Class>test.Agent</Premain-Class>
<Boot-Class-Path>javassist-3.23.1-GA.jar</Boot-Class-Path>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Set-Native-Method-Prefix>true</Can-Set-Native-Method-Prefix>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
google, Baidu has not found anything, and it is not easy to debug itself. It was possible to use ASM
in the past. Thank you in advance