What does it mean to use ${} in Applicationcontext.xml?

Source: Internet
Author: User

in the Applicationcontext.xml file, use ${xxx} to indicate that a variable is called "xxx" inside {XXX}.
Example: Configuring a data connection pool in a applicationcontext.xml file
  
 
  1. <!-- 配置数据链接池 -->
  2. <property name="dataSource">
  3. <bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
  4. <property name="jdbcUrl" value="${jdbcUrl}"></property>
  5. <property name="driverClass" value="${driverClass}"></property>
  6. <property name="user" value="${user}"></property>
  7. <property name="password" value="${password}"></property>
  8. <!-- 其它配置 -->
  9. <!-- 初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default:3 -->
  10. <property name="initialPoolSize" value="3"></property>
  11. <!-- 连接池中保留的最小连接数。Default:3 -->
  12. <property name="minPoolSize" value="3"></property>
  13. <!-- 连接池中保留的最大连接数。Default:15 -->
  14. <property name="maxPoolSize" value="15"></property>
  15. <!-- 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default:3 -->
  16. <property name="acquireIncrement" value="3"></property>
  17. <!--
  18. 控制数据源内加载preparedStatement数量.如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default:0
  19. -->
  20. <property name="maxStatements" value="8"></property>
  21. <!--
  22. maxStatementsPerConnection 定义了连接池内单个连接所拥有的最大缓存statements数。Default:0
  23. -->
  24. <property name="maxStatementsPerConnection" value="5"></property>
  25. <!-- 最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default:0 -->
  26. <property name="maxIdleTime" value="1800"></property>
  27. </bean>
  28. </property>
The part that is identified in the code is the function that uses the ${}. It is equivalent to calling a variable name in Java. In this example, these variables come from a different properties file. The properties are: jdbc.properties (primarily used to store some of the configuration of the JDBC Connection database for the next change without needing to be modified in the Applicationcontext.xml file.) ) Jdbc.properties:
 
   
  
  1. jdbcUrl=jdbc:mysql://localhost:3306/oa
  2. driverClass=com.mysql.jdbc.Driver
  3. user=root
  4. password=
The Jdbcurl in ${jdbcurl} refers to the Jdbcurl in Jdbc.properties.




From for notes (Wiz)

What does it mean to use ${} in Applicationcontext.xml?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.