标签:自动配置 path 文件夹 [] utf-8 str tap res ase
1 <parent> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-parent</artifactId> 4 <version>1.5.6.RELEASE</version> 5 <relativePath/> <!-- lookup parent from repository --> 6 </parent> 7 <dependency> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId>spring-boot-starter-web</artifactId> 10 </dependency>
1 package com.slp; 2 3 import org.mybatis.spring.annotation.MapperScan; 4 import org.springframework.boot.SpringApplication; 5 import org.springframework.boot.autoconfigure.SpringBootApplication; 6 7 @SpringBootApplication 8 @MapperScan("com.slp.mapper") 9 public class DemoApplication { 10 11 public static void main(String[] args) { 12 SpringApplication.run(DemoApplication.class, args); 13 } 14 }
注解@SpringBootApplication标注这是一个Spring Boot应用
main方法使他成为一个主程序,将在应用启动时首先被执行
在工程resource文件夹中创建一个application.properties或application.yum文件,该文件会被自动发布到classpath中,并且被Spring Boot自动读取。
不同文件的配置方式有差异,但是是实现的同样的参数项:
application.yml:
1 server: 2 port: 80 3 tomcat: 4 uri-encoding: UTF-8
application.properties:
1 server.port = 80 2 server.tomcat.uri-encoding = UTF-8
【Spring Boot&&Spring Cloud系列】Spring Boot初识
标签:自动配置 path 文件夹 [] utf-8 str tap res ase
原文地址:http://www.cnblogs.com/dream-to-pku/p/7387949.html