java解压jar包再重新打包jar包以及maven分离依赖包的配置

目录

  • jar 包解压和重新打包命令
  • maven 分离依赖的插件配置

前言
线上包,要加一个加密的配置包,但是不想重新打包过去,只加一个配置类

jar 包解压和重新打包命令

可以用解压软件解压也可以用命令解压

解压jar包命令: jar xvf xxx.jar

打包jar包命令: jar cvfM0 xxx.jar ./* ( * 或者 ./* 都可以)

  1. 先把 这个jar 解压了,然后把 BOOT-INF/lib 里面的jia包该添加添加该替换替换,如果只是增加class类,则到 BOOT-INF/classes 把相应的class放到相应的类路径上

  2. 替换好后,可以用这个指令: jar cvfM0 admin.jar * ( * 表示当前目录所有文件)

  3. 重新打包好后,替换过去重启服务即可


maven 分离依赖的插件配置

在项目的 pom.xml 中添加以下配置即可

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.pluginsgroupId>
            <artifactId>maven-jar-pluginartifactId>
            <configuration>
                <archive>
                    <manifest>
                        
                        <mainClass>com.gov.platform.AdapterApiApplicationmainClass>
                    manifest>
                archive>
                <excludes>
                    
                    <exclude>/application*.propertiesexclude>
                    
                excludes>
                <outputDirectory>${project.build.directory}outputDirectory>
            configuration>
        plugin>

        
        <plugin>
            <groupId>org.apache.maven.pluginsgroupId>
            <artifactId>maven-dependency-pluginartifactId>
            <executions>
                <execution>
                    <id>copy-dependenciesid>
                    <phase>packagephase>
                    <goals>
                        <goal>copy-dependenciesgoal>
                    goals>
                    <configuration>
                        
                        <outputDirectory>${project.build.directory}/liboutputDirectory>
                        <excludeTransitive>falseexcludeTransitive>
                        <stripVersion>falsestripVersion>
                        
                        <includeScope>runtimeincludeScope>
                        
                        <excludeArtifactIds>common-pluginexcludeArtifactIds>
                    configuration>
                execution>
            executions>
        plugin>

        
        <plugin>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-maven-pluginartifactId>
            <configuration>
                <layout>ZIPlayout>
                <addResources>trueaddResources>
                <outputDirectory>${project.build.directory}outputDirectory>
                <includes>
                    <include>
                        <groupId>com.gov.platformgroupId>
                        <artifactId>common-pluginartifactId>
                    include>
                includes>
            configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackagegoal>
                    goals>
                execution>
            executions>
        plugin>

        
        <plugin>
            <groupId>org.apache.maven.pluginsgroupId>
            <artifactId>maven-source-pluginartifactId>
            <executions>
                <execution>
                    <id>attach-sourcesid>
                    <goals>
                        <goal>jargoal>
                    goals>
                execution>
            executions>
        plugin>

        
        <plugin>
            <groupId>com.mysema.mavengroupId>
            <artifactId>apt-maven-pluginartifactId>
            <version>1.1.3version>
            <executions>
                <execution>
                    <goals>
                        <goal>processgoal>
                    goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/javaoutputDirectory>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessorprocessor>
                    configuration>
                execution>
            executions>
        plugin>
        
        <plugin>
			<groupId>pl.project13.mavengroupId>
			<artifactId>git-commit-id-pluginartifactId>
			<configuration>
				<includeOnlyProperties>
					<includeOnlyProperty>git.commit.idincludeOnlyProperty>
				includeOnlyProperties>
			configuration>
		plugin>



















    plugins>
build>

你可能感兴趣的:(Java,maven,java,jar)