Posted on 2015-07-31 14:30
为自己代言 阅读(243)
评论(0) 编辑 收藏
1:spring 4
@Scheduled(cron="0/2 * * * * ?") 注释 在容器中不执行的问题!吗的搞啊整整一天,原因是这个引起的: default-lazy-init="true" 这个配置是懒加载,可以配置到ben 标签中,但是我一个同事配置到<beans 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:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"
default-lazy-init="true"> spring 标签头中了,导致@Scheduled 中配置的类不加载,使用时候才加载。所以不执行定时任务。大家要注意了。
2: spring 3 以后,有一个
<beans profile="product"> 功能 是可以打包时候,随刊切换测试和生产环境配置,但是要注意如果说把war包部暑到容器中(比较tomcat 中)一定激活一个profile;1:可以在web.xml 中配置
<context-param> <param-name>spring.profiles.default</param-name>
<param-value>local</param-value>
</context-param>
2:可以在 JVM启动变量中指定一个比如:'JAVA_HOME':'/opt/apps/jdk1.7.0','JVM_ARGS': '-Dspring.profiles.active=product -Dlog_path=/opt/logs/ -Dappid=11144 -Dfile.encoding=UTF-8 -XX:MaxPermSize=128m -XX:PermSize=128m'} 如果疏忽大意不做配置,导致错误提示是容器启动,老是报依赖注入错误。