Spring boot(1)-快速入门

1.新加一个MAVEN的web项目

2.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 https://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.3.3.RELEASE</version>

        <relativePath/> <!-- lookup parent from repository -->

    </parent>

    <groupId>com.ck</groupId>

    <artifactId>boot</artifactId>

    <version>0.0.1-SNAPSHOT</version>

    <name>boot</name>

    <description>Demo project for Spring Boot</description>



    <properties>

        <java.version>1.8</java.version>

    </properties>



    <dependencies>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>



        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-test</artifactId>

            <scope>test</scope>

            <exclusions>

                <exclusion>

                   <groupId>org.junit.vintage</groupId>

                   <artifactId>junit-vintage-engine</artifactId>

                </exclusion>

            </exclusions>

        </dependency>

    </dependencies>



    <build>

        <plugins>

            <plugin>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-maven-plugin</artifactId>

            </plugin>

        </plugins>

    </build>



</project>

 

3.创建控制器类:

package com.example.demo;





import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

@RestController

public class TestController {



@RequestMapping("/test")

public String test(){

        return "Hello Spring Boot!";

}

}

4.创建Spring Boot启动类:

package com.example.demo;



import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

import org.springframework.boot.autoconfigure.SpringBootApplication;



@SpringBootApplication

@EnableAutoConfiguration

public class BootApplication {



    public static void main(String[] args) {

        SpringApplication.run(BootApplication.class, args);

    }



}

 

5.启动下面如下:


  .   ____          _            __ _ _

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |_\__, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::        (v2.3.3.RELEASE)



2020-09-16 14:56:17.631  INFO 11580 --- [           main] com.example.demo.BootApplication         : Starting BootApplication on DESKTOP-IHNQ3EL with PID 11580 (E:\workspaces\boot\target\classes started by cgsyc in E:\workspaces\boot)

2020-09-16 14:56:17.633  INFO 11580 --- [           main] com.example.demo.BootApplication         : No active profile set, falling back to default profiles: default

2020-09-16 14:56:18.497  INFO 11580 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

2020-09-16 14:56:18.505  INFO 11580 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2020-09-16 14:56:18.505  INFO 11580 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]

2020-09-16 14:56:18.575  INFO 11580 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2020-09-16 14:56:18.575  INFO 11580 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 906 ms

2020-09-16 14:56:18.706  INFO 11580 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

2020-09-16 14:56:18.844  INFO 11580 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''

2020-09-16 14:56:18.850  INFO 11580 --- [           main] com.example.demo.BootApplication         : Started BootApplication in 1.494 seconds (JVM running for 1.817)

 

6.浏览器访问:

 

本文只是让大家了解Spring Boot的快速入门,具体细节本专栏会慢慢讲来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值