引入properties文件

引入properties文件

1.xml方式

1.引入配置

    http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd

2.引入文件

<context:property-placeholder location="classpath:configs.properties"/>

3.获取方式

<property name="name" value="${aa}" />

2.注解方式@PropertySource

@PropertySource(value = "myProperty.properties")

3.properties文件转换为Properties对象

1.引入配置

xmlns:util="http://www.springframework.org/schema/util"
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">

2.引入文件

<util:properties id="cfg" location="classpath:configs1.properties"/>

id为beanid
3.获取方式

#{cfg.cc}

引入properties文件
http://localhost:8080/archives/a34e2970-9b29-418b-ac32-ed28df0efedf
作者
Administrator
发布于
2024年06月11日
许可协议