美文网首页
SpringBoot入门

SpringBoot入门

作者: 帅气的阿斌 | 来源:发表于2020-04-15 12:26 被阅读0次
    创建springboot工程方式一手动设置pom.xml

    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.2.1.RELEASE</version>
        </parent>
    
        <groupId>org.example</groupId>
        <artifactId>springbootstart</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>13</java.version>
            <maven.compiler.source>13</maven.compiler.source>
            <maven.compiler.target>13</maven.compiler.target>
            <encoding>UTF-8</encoding>
        </properties>
    
        <dependencies>
    <!--        web功能-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>2.2.1.RELEASE</version>
            </dependency>
    
    <!--        热部署-->
    <!--        (1)File-Settings-Compiler-Build Project automatically-->
    <!--        (2)ctrl + shift + alt + /(windows) shift + option + command(mac)-->
    <!--选择Registry,勾上 Compiler autoMake allow when app running&ndash;&gt;-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
        </dependencies>
    
    </project>
    
    代码实现

    引导类

    @SpringBootApplication
    public class SpringBootApp {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringBootApp.class);
        }
    
    }
    

    快速创建接口

    @Controller
    public class QuickController {
    
        @RequestMapping("/quickstart")
        @ResponseBody
        public String quick(){
            return "hehehheheheh";
        }
    
    }
    

    热部署

    <!--        热部署-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
    
    创建springboot工程方式二使用向导创建springboot工程

    Spring Initializr->........

    相关文章

      网友评论

          本文标题:SpringBoot入门

          本文链接:https://www.haomeiwen.com/subject/unhigctx.html