第一个springboot程序,初识springboot


1)springBoot三大最基本的部分

建包原则:在启动类同级目录建包  (约定大于配置,因为只有这样建,tomcat才会扫描到,不然没用)

 2)写一个测试接口,测试应用是否启动成功;

 3)访问成功,可以出现结果;

 4)了解pom配置文件;

主要有四个部分:
1)项目元数据信息:创建时候输入的Project Metadata部分,也就是Maven项目的基本元素,包括:groupld、artifactld、version、name、description等;
2)parent:继承spring-boot-starter-parent的依赖管理,控制版本与打包等内容;
3)dependencies:项目具体依赖,这里包含了spring-boot-starter-web用于实现HTTP接口(该依赖中包含了Spring MVC),官网对它的描述是:使用Spring MVC构建Web(包括RESTful)应用程序的入门者,使用Tomcat作为默认嵌入式容器; spring-boot-starter-test用于编写单元测试的依赖包;
4)build:构建配置部分。默认使用了spring-boot-maven-plugin,配合spring-boot-starter-parent就可以把Spring Boot应用打包成JAR来直接运行。

<?xml version="1.0" encoding="UTF-8"?>

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0
    com.example
    demo
    0.0.1-SNAPSHOT
    demo
    Demo project for Spring Boot

    
    
        1.8
        UTF-8
        UTF-8
        2.3.7.RELEASE
    

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

        
        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-dependencies
                ${spring-boot.version}
                pom
                import
            
        
    

    
    
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.8.1
                
                    1.8
                    1.8
                    UTF-8
                
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                2.3.7.RELEASE
                
                    com.example.demo.DemoApplication
                
                
                    
                        repackage
                        
                            repackage