Spring Boot project deployment demonstration, install springboot to quickly generate starter classes and yml plug-ins

1. Spring Boot project deployment demo (simulate local deployment)

Insert picture description hereDemo package this project:
Insert picture description here

  1. Add the pom.xml plug-in of the project; add the spring-boot-maven-plugin plug-in explicitly in pom.xml, otherwise the jar manifest
    file cannot be generated , causing the typed jar to fail to run with the command:
    Insert picture description here
    pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>

    </parent>
    <groupId>cn.itcast</groupId>
    <artifactId>Spingboot_day1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.version>1.9</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--java配置配置数据库要的-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.10</version>
        </dependency>

        <!--Spring Boot的属性注入需要的-->
        <dependency>
            <groupId> org.springframework.boot </groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <!--不传递依赖-->
            <optional>true</optional>
        </dependency>

        <!--lombok需要的-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!--事务和连接池需要的-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.46</version>
        </dependency>

        <!--mybatis需要的-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.1</version>
        </dependency>


        <!--mybatis通用mapper需要的-->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>2.1.5</version>
        </dependency>

        <!--Junit需要的-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <!--redis需要的-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
    </dependencies>

    <!--springboot部署需要-->
    <build>
        <plugins>
            <!-- 打jar包时如果不配置该插件,打出来的jar包没有清单文件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
  1. Use the maven command package to package:
    (The project does not need to be started)
    Insert picture description hereAfter that, there will be the following jar package in the target directory under the project: Insert picture description hereThen the local path of the jar above:
    Insert picture description hereRun:
    Then open cmd here (no administrator is required):
    Input:
    xx.jar above java -jar
    Insert picture description here

The operation is successful, and then we can directly access the resources just deployed in the browser without starting the idea:
such as input: the
Insert picture description heretest is successful! ! !

Second, install springboot to quickly generate the starter class and yml plug-in

When applying the spring boot project; under normal circumstances, it is necessary to create the startup boot class Application.java and application.yml configuration files, and the content is the same; for convenience, you can install an IDEA plug-in JBLSpringBootAppGen and right-click on the project. Automatically generate startup boot class Application.java and application.yml configuration files.
Insert picture description here
After downloading, right-click on any maven project or src directory in IDEA and select JBLSpringBootAppGen. Insert picture description here
Insert picture description here
After clicking OK, the following content will be found in the project:Insert picture description here

Guess you like

Origin blog.csdn.net/GLOAL_COOK/article/details/113940437