Multi-module maven + springboot project jar packaging, operation, deployment of linux (centos) server

1. maven project structure:

project address:

https://github.com/KouReal/Rpc-Netty-Registry

 

 

 2. Before not added in pom.xml spring-boot-maven-build plug-in, only to write a maven-compiler-plugin This plug-in parent pom.xml in the project, so the project can only run as the main class selected in eclipse java application, and later added (the parent project and sub-modules are added):

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.8.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

3. After cmd can be cut to the root directory of a module of the project, such as RegistryCenter (starting with the highest priority), run mvn clean package -Dmaven.test.skip = true pack, run mvn spring-boot: run -Dmaven.test .skip = true run (first run the display interface will download a lot of files springboot-core slfj and so there are other plug-ins, run the eclipse will not be displayed)

 

 

 Note: Error command Demo: java command did not use maven plugin spring-boot, you will get an error: "NoClassDefFoundError"

 

 

 

 Later, refer to the official documentation, learning to mvn spring-boot: repackage command, by this command package, you can use java -jar run,

 

 Thus this module: mvn spring-boot: repackage -Dmaven.test.skip = true

result:

 

 查stackoverflow,应该用:mvn clean install spring-boot:repackage -Dmaven.test.skip=true

 

 You can then use the target directory run java -jar jar package:

 

 

 

 Use the command role is to repackage the original maven jar file packaged or packaged war file further add some resource-dependent runtime, generate a bigger jar package, this jar package can be run with the java -jar.

 

Guess you like

Origin www.cnblogs.com/CreatorKou/p/11504387.html