服务器:
- tomcat
- jetty
- undertow
- 可以在springboot中切换使用,springboot默认的是tomcat,修改切换时在pom.xml,
exclusions去tomcat再切换需要的服务器
application.properties有中文配置需要查询他项目目录的properties文件有没有转义,如果没有,到时读取(@Value("${book.name}")会出现乱码,解决:
@PropertySource("classpath:application.properties") | 手动配置spring |
@Value("${book.name}") | 注入properties的值 |
| @ConfigurationProperties(prefix = "book") | 指定前缀springboot,不用写value支持数组注入 |
.properties(内部是hashtable:无序的)
#springboot中的application.properties,不用手动引入(@PropertySource("classpath:application.properties"))
#@ConfigurationProperties(prefix = "book")配置前缀,对于名字自动回注入
#book属性
book.name=三国演义
book.author=罗贯中
#list
book.tags[0]=通俗小说
book.tags[1]=玄幻小说
#list
book.author[0].name=文静
book.author[0].age=20
book.author[1].name=jason
book.author[1].age=21
#tomcat配置
#例如get请求乱码
server.tomcat.uri-encoding=utf-8
#以下修改时针对所有容器,而非只针对tomcat
#修改项目的端口号
server.port=8888
#修改项目的工程名
server.servlet.context-path=/s
.yaml(内部是linkedhashmap:有序的)
server: port: 8081 servlet: context-path: /s book: name: 三国演义 author: 罗贯中 tags: - 通俗小说 - 小说 authors: - name: aaa age: 99 - name: bbb age: 100#配置生产环境 spring: profiles: active: prod,ds



