Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Spring @ value is unable to take values. How to solve multiple properties files

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article "spring @ value can not take the value of multiple properties files how to solve" most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "spring @ value can not take a value of multiple properties files how to solve" article bar.

@ Value cannot value more than one properties file spring

When using the SSM framework, I load two configuration files (properties), one is the database configuration file and the other is the resource configuration information file. Either the connection information of the database is parsed to ${jdbc.url} or the information of the resource file cannot be parsed:

It looks like this:

Many methods on the Internet have been tried, but to no avail, or database connection error. Or there is no value here.

Go straight to your own solution.

Configuration file:

Configuration file:

Value method:

Note: this is not ${}, but # {}

My spring version is 4.1.3.

Spring cannot read the value of the properties file

Use

Configuration properties file, read using spEl expression in controller (format of spEL expression: @ Value (# {id ['property name']})).

Reason

The configuration information is configured in the configuration file of spring, where the @ Controller comment is excluded from scan.

Solution method

You need to configure it in the springMVC configuration file, ok.

The above is about the content of the article "how to solve the problem of multiple properties files that cannot be valued by spring @ value". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report