尚硅谷springboot学习4-helloworld探究

  1、POM文件

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

  他的父项目是

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-dependencies</artifactId>
  <version>1.5.9.RELEASE</version>
  <relativePath>../../spring-boot-dependencies</relativePath>
</parent>

  他来真正管理Spring Boot应用里面的所有依赖版本;是Spring Boot的版本仲裁中心;以后我们导入依赖默认是不需要写版本;(没有在dependencies里面管理的依赖自然需要声明版本号)

  2、启动器

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

  spring-boot-starter:spring-boot场景启动器;帮我们导入了web模块正常运行所依赖的组件;

  Spring Boot将所有的功能场景都抽取出来,做成一个个的starters(启动器),只需要在项目里面引入这些starter相关场景的所有依赖都会导入进来。要用什么功能就导入什么场景的启动器

<?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-starters</artifactId>
        <version>1.5.19.RELEASE</version>
    </parent>
    <artifactId>spring-boot-starter-web</artifactId>
    <name>Spring Boot Web Starter</name>
    <description>Starter for building web, including RESTful, applications using Spring
        MVC. Uses Tomcat as the default embedded container</description>
    <url>http://projects.spring.io/spring-boot/</url>
    <organization>
        <name>Pivotal Software, Inc.</name>
        <url>http://www.spring.io</url>
    </organization>
    <properties>
        <main.basedir>${basedir}/../..</main.basedir>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
    </dependencies>
</project>

原文地址:https://www.cnblogs.com/liunianfeiyu/p/10354025.html

时间: 2024-08-30 15:08:50

尚硅谷springboot学习4-helloworld探究的相关文章

尚硅谷springboot学习14-自动配置原理

配置文件能配置哪些属性 配置文件能配置的属性参照 自动配置的原理 1).SpringBoot启动的时候加载主配置类,开启了自动配置功能 @EnableAutoConfiguration 2).@EnableAutoConfiguration 作用: 利用EnableAutoConfigurationImportSelector给容器中导入一些组件? 可以查看selectImports()方法的内容: List<String> configurations = getCandidateConfi

尚硅谷springboot学习3-helloworld程序

1.环境准备 –jdk1.8:Spring Boot 推荐jdk1.7及以上:java version "1.8.0_112" –maven3.x:maven 3.3以上版本:Apache Maven 3.3.9 –IntelliJIDEA2017:IntelliJ IDEA 2017.2.2 x64.STS –SpringBoot 1.5.9.RELEASE:1.5.9: 2.MAVEN设置 <profile> <id>jdk-1.8</id> &

尚硅谷springboot学习5-主入口类说明

package com.atguigu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @SpringBootApplication 来标注一个主程序类,说明这是一个Spring Boot应用 */ @SpringBootApplication public class HelloWorldM

尚硅谷springboot学习6-eclipse创建springboot项目的三种方法(转)

方法一 安装STS插件 安装插件导向窗口完成后,在eclipse右下角将会出现安装插件的进度,等插件安装完成后重启eclipse生效 新建spring boot项目 项目启动 方法二 1.创建Maven项目 2.选择项目类型 3.选择项目 4.编写项目组和名称-finish即可 5.修改pom.xml文件 <!-- spring boot基本环境 --> <parent> <groupId>org.springframework.boot</groupId>

尚硅谷springboot学习7-yaml配置文件

SpringBoot使用一个全局的配置文件,配置文件名是固定的: application.properties application.yml 配置文件的作用:修改SpringBoot自动配置的默认值:SpringBoot在底层都给我们自动配置好: YAML(YAML Ain't Markup Language) ? YAML A Markup Language:是一个标记语言 ? YAML isn't Markup Language:不是一个标记语言: 标记语言: ? 以前的配置文件:大多都使

尚硅谷springboot学习9-配置文件值注入

首先让我想到的是spring的依赖注入,这里我们可以将yaml或者properties配置文件中的值注入到java bean中 配置文件 person: lastName: hello age: 18 boss: false birth: 2017/12/12 maps: {k1: v1,k2: 12} lists: - lisi - zhaoliu dog: name: 小狗 age: 12 javaBean: package com.atguigu.springboot.bean; impo

尚硅谷springboot学习[email&#160;protected],@ImportResource,@Bean

@PropertySource 使用指定的属性文件而不一定是application.xxx 同样可以注入相关内容 @ImportResource 导入Spring的配置文件,让配置文件里面的内容生效: Spring Boot里面没有Spring的配置文件,我们自己编写的配置文件,也不能自动识别: 想让Spring的配置文件生效,加载进来:@ImportResource标注在一个配置类上 @Bean SpringBoot推荐给容器中添加组件的方式:推荐使用全注解的方式 package com.at

尚硅谷springboot学习13-配置的加载

配置可以有很多不同的来源,也有不同的加载顺序,下面来具体的看一下 配置文件加载位置 spring boot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 –file:./config/ –file:./ –classpath:/config/ –classpath:/ –以上是按照优先级从高到低的顺序,所有位置的文件都会被加载,高优先级配置内容会覆盖低优先级配置内容. 上面四个位置在一个项目中是这样

尚硅谷springboot学习17-SpringBoot日志

SpringBoot使用它来做日志功能: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> 底层依赖关系 总结: ? 1).SpringBoot底层也是使用slf4j+logback的方式进行日志记录 ? 2).SpringBoot也把其他