SpringBoot packaging problems that need attention

Copyright: please leave a message like Give me praise problematic -------------------------------- will be updated from time to time , because learning, so happy, because the share, so convenient! Reprint please indicate the source, ha ha! https://blog.csdn.net/Appleyk/article/details/84817333

First, the module is labeled jar package, the package does not contain a jar-dependent third-party packages

 

 

Usage scenarios: When teamwork development, use svn or git project code hosting, each person is responsible for a module that different modules for different team members have rights division, responsible for their own module demo is open, does not belong that part of their module, labeled jar package is required to add a local dependency benefits of doing so is that the code is easy to manage, and less dependent on local, jar package all get!

 

 

The solution: the need to increase in the pom configuration is as follows:

 

 

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies -->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>util.Microseer</mainClass>
                        </manifest>
                    </archive>

                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- bind to the packaging phase -->
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

 

 

 

 

 

Second, the module is labeled war package, the package does not include local war dependent jar file

 

 

Usage scenarios: the module package to be labeled as war, starting to be released under the local tomcat test and correct, demo can be submitted to the svn or git, because the person in charge of each module is independent, to be attached to other modules jar package, and these jar package will be added to the project in the form of local resource file lib. for the current module mvn package, under normal circumstances, labeled the war package that does not include local jar package under the lib file

 

 

 

 

Dependency in pom:

 

     <dependency>
            <groupId>com.appleyk</groupId>
            <artifactId>xxxx.common</artifactId>
            <version>0.1.0-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/onegis.common.jar</systemPath>
        </dependency>

 

 

 

The solution: the need to increase in the pom configuration is as follows:

 

 

<build>
        <finalName>xxx.model.web</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                            <includeScope>system</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
 </build>

 

 

Effect (the former is not configured, war package does not contain any of these four local packets dependent jar):

 

 

Guess you like

Origin blog.csdn.net/Appleyk/article/details/84817333