unzip -p charles.jar META-INF/MANIFEST.MF 

https://www.ibm.com/developerworks/cn/java/j-lo-spring-boot/index.html

 

首先是增加了<parent>
增加父pom比较简单,而且spring-boot-starter-parent包含了大量配置好的依赖管理,在自己项目添加这些依赖的时候不需要写<version>版本号。

使用父pom虽然简单,但是有些情况我们已经有父pom,不能直接增加<parent>时,可以通过如下方式:

<dependencyManagement>
     <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.2.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

在我们开发过程中,我们需要经常修改,为了避免重复启动项目,我们可以启用热部署。

Spring-Loaded项目提供了强大的热部署功能,添加/删除/修改 方法/字段/接口/枚举 等代码的时候都可以热部署,速度很快,很方便。

想在Spring Boot中使用该功能非常简单,就是在spring-boot-maven-plugin插件下面添加依赖:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>springloaded</artifactId>
        <version>1.2.5.RELEASE</version>
    </dependency>
</dependencies>

添加以后,通过mvn spring-boot:run启动就支持热部署了。

 

最近在学习java agent,需要在生成的jar包里面的 META-INF/MAINIFEST.MF 必须包含 Premain-Class这个属性。采用MAVEN的maven-jar-plugin插件完成。

maven-jar-plugin插件默认生成的MAINIFEST.MF文件包含以下几项:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: ${user.name}
Build-Jdk: ${java.version}


现在要新增一个Premain-Class属性,配置如下:

<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>
					com.xzq.test.PreAgent
				</Premain-Class>
			</manifestEntries>
		</archive>
	</configuration>