Skip to content

yoqu/maven-plugin-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Plugin Stater

A spring boot applicaiton quick running script.

What this?

With the rapid development of spring boot, the deployment of a service is now simpler and easier, especially the rise of microservices, docker containerization. Make the spring boot jar advantage more and more only need to use java -jar xxx.jar to start. But at the same time, for traditional enterprises and companies, do not introduce docker containerized deployment plan, and want to use jar package to start independently will encounter the following problems

  1. If you need to implement custom jvm parameters or background hangs, you need to manually write the script (each console write code is too tired)
  2. The configuration file modification in the jar is very troublesome (sometimes it needs operation and maintenance to maintain the configuration. If you have problems with the configuration, you need to repackage it. It is too time-consuming to encounter the turtle speed network copy package)
  3. A server has multiple microservices running, and it doesn't know what service is a certain process (it is known through port checking, but this seems a bit cumbersome).

In summary, this gadget automatically generates startup, stop, and restart scripts after the project is compiled. The deployment package operation and maintenance generated by the user after compilation can be run with only two lines of commands.

1: unzip xxx.war

2:sh xxx/bin/start.sh.

Note:Use tomcat war package is not within the scope of this discussion deployment.

The compiled directory structure of the project:

├── META-INF
├── WEB-INF
│   ├── classes
│   └── lib
└── bin
    ├── restart.sh
    ├── start.sh
    └── stop.sh

Feature

  • Automatically generate startup scripts during the packaging process
  • No code intrusion, no need to increase jar package dependencies
  • Support jvm parameter custom configuration
  • Support personalized startup class lookup
  • Support remote debug,jmx
  • Jps command can display the service name

Quick Start

  1. Set the package mode to war in the pom file.
	<packaging>war</packaging>
  1. The following configuration is introduced under the plugins that set the pom.xml file.
<plugin>
    <groupId>com.uyoqu.framework</groupId>
	<artifactId>maven-plugin-starter</artifactId>
	<version>1.0.0</version>
    <executions>
        <execution>
        <phase>package</phase>
        <goals>
            <goal>bin</goal>
        </goals>
        </execution>
    </executions>
</plugin> 

The plug-in supports configuration. It can specify the startup main function and jvm parameters. For Spring boot, it supports automatic query of MainClass without manual filling.

example:

<plugin>
    <groupId>com.uyoqu.framework</groupId>
	<artifactId>maven-plugin-starter</artifactId>
	<version>1.0.0</version>
    <executions>
        <execution>
        <phase>package</phase>
        <goals>
            <goal>bin</goal>
        </goals>
        </execution>      
    </executions>
  	<configuration>
            <jvms>
                <jvm>-server</jvm>
                <jvm>-Xmx512m</jvm>
            </jvms>
            <mainClass>com.xxx.xxx</mainClass>
            <matchClass>App</matchClass>
     </configuration>
</plugin>        

Note

  • The jvm parameter is configured in jvms. If the user does not perform this configuration, the default parameters will be filled in the bin script.
  • The matchClass parameter can be configured to support rules for finding matches.
  • If the mainClass is not configured, the default class with the @SpringBootApplication annotation is found.
  • There can only be one startup class, and if it matches more than one, it will report an error.