1.在web项目的src目录下新建setting.properties的文件,内容如下:

version=1

 

2.在spring的xml配置文件中加入以下配置:

<!-- 使用注解注入properties中的值 -->

   <bean >

       <property name="locations">

           <list>

               <value>classpath:setting.properties</value>

           </list>

       </property>

       <!-- 设置编码格式 -->

       <property name="fileEncoding" value="UTF-8"></property>

   </bean>

 

3.在controller类中加入以下注解即可

  @Value("#{setting[version]}")

   private String version;

相关文章:

  • 2021-09-02
  • 2021-11-16
  • 2023-04-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-12-26
  • 2021-06-17
猜你喜欢
  • 2021-07-12
  • 2021-11-22
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2023-02-04
  • 2021-10-21
相关资源
相似解决方案