美文网首页
Day06:SpringBoot配置

Day06:SpringBoot配置

作者: 宇宙超人喵学长 | 来源:发表于2017-07-18 17:11 被阅读0次
  • 1、pom依赖
  • starter pom
    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
  • spring boot编译插件

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>

  • 2、注解
  • @SpringBootApplication:开启自动配置,组合了@Configuration、@EnableAutoConfiguration、@CompnnentScan
  • 3、定制启动banner
  • 在src/main/resource下新建banner.txt
  • http://patorjk.com/software/taag生成字符,复制到txt中
  • 关闭:main函数中修改:app.setShowBanne(false);
  • 4、配置文件
  • server.context-path=/helloboot //修改路径
  • logging.file=D:/mylog/log.log //设置日志文件
  • logging.level.包名=级别 //配置日志级别
  • 4.1、使用xml配置
  • @ImportResource({"classpath:some--
  • context.xml","classpath:another-context.xml"})
  • @PropertySource指定porperties文件位置,并通过@Value注入值@Value("${book.author}")
  • 添加配置,在bean上注解@ConfigurationProperties(prefix = "author")
  • 5、profile配置:针对不同的环境的不同配置
    application-{profile}.properties
    在application.properties中设置spring.profiles.active=profilename来指定活动的profile

相关文章

网友评论

      本文标题:Day06:SpringBoot配置

      本文链接:https://www.haomeiwen.com/subject/jcyhkxtx.html