SpringBoot2.0.2 不使用parent作为maven单继承方式操作 : org.springframework.boot : spring-boot-dependencies : 2.0.

1、pom配置方式



    4.0.0

    com.springboot
    quick_start
    0.0.1-SNAPSHOT
    jar

    quick_start
    http://maven.apache.org
    Demo project for Spring Boot

    
        UTF-8
        UTF-8
        1.8
        1.8
        1.8
    

    
        
        
            org.springframework.boot
            spring-boot-dependencies
            2.0.2.RELEASE
            import
            pom
        


        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


2、实体类编写

package com.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

/******************************
 * @Author : liuyang
 * @ClassName : QuickStartApplication
 * @Date : 2018 五月  20
 * @Time : 01:05:59
 * @Type : SpringBoot
 * @Version : 1.0
 * @Return :
 * @Description :
 *******************************/

@SpringBootApplication
public class QuickStartApplication {

    @Bean
    public Runnable createRunnable() {

        return () -> {
            System.out.println("Spring Boot is Run");
        };

    }

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(QuickStartApplication.class,args);
        applicationContext.getBean(Runnable.class).run();
    }
}

 

这个在官方文档上也有具体写:

                 https://docs.spring.io/spring-boot/docs/2.0.2.RELEASE/reference/htmlsingle/#boot-documentation

SpringBoot2.0.2 不使用parent作为maven单继承方式操作 : org.springframework.boot : spring-boot-dependencies : 2.0._第1张图片

你可能感兴趣的:(学习)