SpringBoot启动端口+访问路径

配置文件:

server.port=9090
server.context-path=/springboot

现在只能用http://127.0.0.1:9090/springboot才能访问到项目

SpringBoot配置文件yml

下面讲一下SpringBoot中另外一种格式的配置文件,名为application.yml的配置文件,这种配置文件更方便我们使用,有提示功能,而且SpringBoot也是默认去读取这个格式的配置文件,我们这里改变一下配置文件的风格。

原来的配置文件:

server.port=9090
server.context-path=/springboot

spring.datasource.url=jdbc:mysql://localhost:3306/springboot_mjxy
spring.datasource.username=root
spring.datasource.password=admin
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#mybatis.mapper-locations=classpath:mapper/*.xml
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
name=majiaxueyuan

下面我们把它改造成application.yml的风格,非常有层次感

server:
 port: 80
 context-path: /springboot
spring:
 datasource:
   username: root
   password: admin
   url: jdbc:mysql://localhost:3306/springboot_mjxy?characterEncoding=utf8
 thymeleaf:
   cache: false
   mode: LEGACYHTML5
   prefix: classpath:/templates/
   suffix: .html

如果没有高亮,请在eclipse中安装SpringToolsSuits。然后重启eclipse,选择打开方式就可以高亮了。

SpringBoot多环境区分

我们可以创建多个配置文件,只需要在源配置文件上面增加下面的一个配置

spring:

profiles:

active: lx

这样系统就会优先去扫描配置文件是application-lx.yml的配置文件

SpringBoot打包发布

项目右键–>Run As…–>Maven Build…–>goals–>clean package

或者进入项目目录,命令行mvn clean package

如果报错没有主清单,在pom文件中新增下面代码

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<maimClass>com.majiaxueyuan.App</maimClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

最新文章

  1. noi 1.5 43:质因数分解
  2. AspNetUsers
  3. 推荐使用C++ 11
  4. 《深入浅出嵌入式底层软件开发》—1. ARM汇编编程基础
  5. Java反射机制学习
  6. 执行yiic webapp命令时报错:php.exe不是内部或外部命令,也不是可运行的程序
  7. 表单中GET与POST的区别
  8. RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2-&gt;用户管理模块新增“重置用户密码”功能
  9. 解决安卓JNI native 线程不能正常退出问题二
  10. Oracle 11g OGG 修改 trail 文件大小
  11. vb.net 水晶報表CrystalReport 動態設定資料庫來源
  12. openstack-云计算概述
  13. Python全栈问答小技巧_1
  14. AMQP &amp; JMS对比(转载)
  15. 索引唯一性扫描(INDEX UNIQUE SCAN)
  16. (原)luarocks更新某个模块
  17. Microsoft Dynamics CRM4.0 和 Microsoft Dynamics CRM 2011 JScript 方法对比
  18. Git之版本回退及回滚
  19. CSS节选——选择器
  20. jquery选择器详细说明

热门文章

  1. selenium基础-图形验证码
  2. CentOS增加swap分区大小
  3. 一些CSS3新技术
  4. Ubantu18.04安装WPS
  5. Impala查询执行过程
  6. VBA文件对话框的应用(VBA打开文件、VBA选择文件、VBA选择文件夹)
  7. 360自动抢票还不够,几行js代码设置无人值守
  8. C/C++ 公有函数无法返回私有的类对象解决方案
  9. 软件设计师_朴素模式匹配算法和KMP算法
  10. VPGAME的Kubernetes迁移实践