首页 > 编程知识 正文

载入profiles是有什么用,springmvc注解有哪些

时间:2023-05-05 10:04:23 阅读:109005 作者:2957

yml配置文件是我们在实际工作中常用的配置文件格式,有时会遇到我们从未遇到过的新表达。 下面介绍我在工作中遇到的日志配置文件的有趣表达。

spring.profiles.active=@ profiles.active @的含义spring.profiles.active=@ profiles.active @实际上是与maven profile合作

运行mvn clean package -P test命令时,@profiles.active@将替换为test

打开jar包时,您将看到以下内容:

外壳

生成springboot项目

这里使用idea构筑,但省略了这个过程

配置pom文件

个人资料个人资料! ---生产环境--- id prod/idpropertiesprofiles.active prod/profiles.active/properties/profile! ---本地开发环境----id dev/idpropertiesprofiles.active dev/propertiesactivationactivebydefaulttrue/aactive/proprofiles。 idpropertiesprofiles.active test/profiles.active/properties/profile/profiles默认值3358www.Sina.sina

配置多个配置文件

dev配置

请注意此处的profiles.active和pom文件之间的对应。 spring.profiles.active=@ profiles.active @ http://www.Sina.com /

name='dev' application.properties

name='prod' application-dev.properties

name='test '测试的controller @ restcontrollerpublicclasshellocontroller { @ value ($ { name ) )私有字符串名称; @ request mapping (value={ '/hello ' },method=RequestMethod.GET ) public String say ) ) { return name; 开始测试

application-prod.properties

默认值为dev。 如果要使用prod配置文件,请如上图所示选择prod并重新启动项目,注意以下导入

d :dev _ codeprofiles-demotarget curl http://localhost 33608080/hello

' prod '

打包

这里可以用idea包装,也可以用命令行包装。

如果你要使用命令

mvn clean package -P dev

使用dev配置

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。