1.pom添加依赖以及配置

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

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>

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

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

2.设置controller类

@RestController
public class helloController {
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello spring-boot";
    }
}

3.设置启动类

@SpringBootApplication
//对相应的包进行扫描
@ComponentScan(basePackages = {"org.example.springboot.controller"})
public class starter {
    public static void main(String[] args) {
        SpringApplication.run(starter.class);
    }
}

4.自定义banner(在resource中设置banner.txt,项目启动时自动读取)

@SpringBootApplication
//对相应的包进行扫描
@ComponentScan(basePackages = {"org.example.springboot.controller"})
public class starter {
    public static void main(String[] args) {
        SpringApplication.run(starter.class);
    }
}