标签:项目笔记
项目笔记1:
applicationContext-integration.xml
<?xml version="1.0" encoding="UTF-8"?> <beans default-autowire="no" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd" > <context:component-scan base-package="com.sinodynamic.hkgta.integration"/> <util:properties id="oasisProperties" location="classpath:config/oasis.properties" /> <context:property-placeholder properties-ref="oasisProperties" ignore-unresolvable="true"/> </beans>
oasis.properties
pmsapi.url=https://localhost:8088/pmsws/xmlhtng.php posapi.url=https://localhost:8089/posws/xmlhtng.php oasis.host=localhost:8088 oasis.login.url=https://localhost:8088/hotel/code/login.php
PMSApiServiceImpl.java
public class PMSApiServiceImpl implements PMSApiService {
protected final Logger logger = Logger.getLogger(PMSApiServiceImpl.class);
@Autowired
@Resource(name="jaxbMarshaller")
private Jaxb2Marshaller jaxbMarshaller ;
@Value(value ="#{oasisProperties[‘pmsapi.url‘]}")
private String apiUrl;
@Value(value="#{oasisProperties[‘posapi.url‘]}")
private String posApiUrl;
@Value(value ="#{oasisProperties[‘paramName‘]}")
private String paramName;
@Value(value ="#{oasisProperties[‘socketTimeout‘]}")
private int socketTimeout;
@Value(value ="#{oasisProperties[‘connectTimeout‘]}")
private int connectTimeout;
@Value(value ="#{oasisProperties[‘oasis.host‘]}")
private String oasisHost;
@Value(value ="#{oasisProperties[‘oasis.login.url‘]}")
private String loginUrl;
//.......
}Spring Annotation方式读取注入properties属性值
标签:项目笔记
原文地址:http://2311203.blog.51cto.com/2301203/1744741