1
//启动服务的脚本
/etc/init.d/tomcat-oa-building.xml 配置脚本
export tomcatName=tomcat-oa-apkbuilding //项目名称
export JRE_HOME=/data/jdk1.8.0_92//未改动
export CATALINA_HOME=/data/tomcat-source//未改动
export CATALINA_BASE=/data/tomcat-oa-apkbuilding//存放位置
2
/data/tomcat-oa-apkbuilding/conf/server.xml 配置了host和war包位置等 我配置的是9172
<Connector port="9172" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="9172" protocol="AJP/1.3" redirectPort="8443" />
------------------------------
<Host name="localhost" appBase="/data/tomcat-oa-apkbuilding/webapps/apkbuilding-ui"
unpackWARs="true" autoDeploy="true">
<Context docBase="/data/tomcat-oa-apkbuilding/webapps/apkbuilding-ui.war" path="/" reloadable="true"/>
3
/data/conf/apkbuilding.oa.gyyx.cn/放置了项目用到的配置文件 链接数据库配置参数等
其它
为了可以在服务器上和本机测试时使用不同的路径。
web.xml中 development代表本地,上传时改为production
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>development</param-value>
</context-param>
--------------------------------------------------------------------------
spring-root.xml中添加配置
<beans profile="development">
<bean id="propertyConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:D:/DataConfig/sqlServer.properties</value>
<value>file:D:/DataConfig/apkBuildingValues.properties</value>
</list>
</property>
</bean>
</beans>
<beans profile="production">
<bean id="propertyConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:/data/conf/apkbuilding.oa.gyyx.cn/sqlServer.properties</value>
<value>file:/data/conf/apkbuilding.oa.gyyx.cn/apkBuildingValues.properties</value>
</list>
</property>
</bean>
</beans>
--------------------------------------------------------------------------------------------------
以上配置开始没有问题,后来在java代码通过注解获取apkBuildingValues.properties属性时获取不到
@Value("${apk.building.resources.path}")
protected String resourcesPath;
我的理解是在java代码中获取需要context相关。
在servlet.xml添加,配置之后可以了
<beans:beans profile="development">
<!-- <context:property-placeholder location="file:D:/DataConfig/sqlServer.properties"/> -->
<context:property-placeholder location="file:D:/DataConfig/apkBuildingValues.properties"/>
</beans:beans>
<beans:beans profile="production">
<context:property-placeholder location="file:/data/conf/apkbuilding.oa.gyyx.cn/apkBuildingValues.properties"/>
<!-- <context:property-placeholder location="file:/data/conf/mobile.oa.gyyx.cn/sqlServer.properties"/> -->
</beans:beans>