How to deploy jar project to Windows server and run it? (Mevan project)

I wrote a small Netty project during the summer vacation and thought I would have a server to deploy it on.

First package the project into a jar: (only the mevan project I use is operated here)

1. Add the plugin to the pom file:

<plugins>
            <!--对相关的jar版本进行说明-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <!--打包成jar-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <!--指定主类,这个很重要!-->
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.App</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--将依赖项一同打包-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.App</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

2. Pack as shown in the figure:

 ps: clean it before packaging

3. After packaging is completed, find it in the project root directory and upload it to the server

 4. Enter the following command in cmd to run it

 

Guess you like

Origin blog.csdn.net/weixin_60246228/article/details/132274749