今天项目中遇到一个问题,一个方法在服务启动后会自动被执行,查看了下配置未发现有定时的配置。但是后来发现是spring配置了启动时默认加载了方法。

代码:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byName" default-lazy-init="true"> <bean id="resize1080iThreadPool" class="com.*.Resize1080iThreadPool" lazy-init="false"
scope="singleton" init-method="triggerThreadPool">
</bean> <context:component-scan base-package="com.haier" />
</beans>

说明:

lazy-init="false":默认启动是spring自动实例化此类。

init-method="triggerThreadPool":实例化后默认执行的方法。

结果:

这样就想的通了,启动服务,triggerThreadPool方法自动被执行了。

参考资料:http://blog.csdn.net/fhx007/article/details/7016704

框架技术--Spring自动加载配置的更多相关文章

  1. Yaf框架下类的自动加载

    前面两篇博客分别讲述了PHP自带的类加载和composer中类的自动加载,其实Yaf框架也实现了基于PSR0和PSR4的类的自动加载.根据我对Yaf下类的自动加载方式的理解写下这篇博客.由于接触Yaf ...

  2. PHP设计模式:类自动载入、PSR-0规范、链式操作、11种面向对象设计模式实现和使用、OOP的基本原则和自动加载配置

    一.类自动载入 SPL函数 (standard php librarys) 类自动载入,尽管 __autoload() 函数也能自动加载类和接口,但更建议使用 spl_autoload_registe ...

  3. PHP自动加载配置ArrayAccess类

    ArrayAccess是PHP的类,可以把对象当成数组来使用访问. Config.php   配置类 <?php namespace IMooc; class Config implements ...

  4. YII框架的类自动加载机制

    YII之所以能实现快速的自动加载类文件,是因为它通过两种途径来实现. 先看文件 vendor\yiisoft\yii2\BaseYii.php 里面的 autoload 方法 public stati ...

  5. 010.CI4框架CodeIgniter, autoload自动加载自己的helper函数类

    01.自己定义了一个helper类,里面有个函数用来输出 02.定义一个Controller基本类,我们以后用到的Controllers类都继承自这个类.其中自动加载helper函数如图所示: 03. ...

  6. spring boot 加载配置 文件

    在springboot启动的过程中,默契情况下会在classpath路径下加载application.properties当做系统配置文件,但有时候我们想要替换成另一个文件,可以 通过以下方式:   ...

  7. ASP.NET MVC搭建项目后台UI框架—11、自动加载下拉框查询

    ASP.NET MVC搭建项目后台UI框架—1.后台主框架 需求:在查询记录的时候,输入第一个字,就自动把以这个字开头的相关记录查找出来,输入2个字就过滤以这两个子开头的记录,依次类推. 突然要用到这 ...

  8. PHP 命名空间以及自动加载(自动调用的函数,来include文件)

    这篇文章的目的是记录 1. php中的自动加载函数 __autoload(), 和 spl_autoload_register()函数, 2 .php中命名空间的使用. 一.当不使用命名空间的时候 a ...

  9. Spring Boot加载配置文件

    问题1:Spring如何加载配置,配置文件位置? 1.默认位置: Spring Boot默认的配置文件名称为application.properties,SpringApplication将从以下位置 ...

随机推荐

  1. qt学习:信号,槽

    [C.GUI.Qt.4编程(第二版)](加)布兰切特,(英)萨默菲尔德.扫描版[学习库www.xuexi111.com].pdf 信号和槽是Qt编程的基础,它可以让各种对象联系在一起. 1. 使用co ...

  2. 前自加(++a)与后自加(a++)的差别

    自加是自己加1的操作.比如a++ 是a+1 ,变量a变成了 a+1的值. 如果是简单的只做 a++:或者++a的语句,效果是一样的. 但是如果嵌入到复杂的语句中,比如 b = a++: 和 b = + ...

  3. 写了个小爬虫,为何用上代理ip总是出现错误。

    import urllib.request import re import os import random import threading def url_open(url): #在第8到第12 ...

  4. sql server 修改表自增列的值

    Create PROCEDURE [dbo].[SP_UpdateIdentityId] ( ) , @beforeId INT , @afterId INT ) AS BEGIN IF @befor ...

  5. [置顶] What is the difference between Category and Class Extension?

    细心的人会发现当我们new 一个文件的时候会发现下图的部分. 但是这个问题来了Category 和 Extension 就近又什么区别呢? 1:什么是Category? 实现这样一种场景,当我们用我们 ...

  6. 多线程中Local Store Slot(本地存储槽)

    在Java中有一种ThreadLocal机制,为每一个使用该变量的线程都提供一个变量值的副本,是每一个线程都可以独立地改变自己的副本,而不会和其它线程的副本冲突.从线程的角度看,就好像每一个线程都完全 ...

  7. Codeforces Gym10008E Harmonious Matrices(高斯消元)

    [题目链接] http://codeforces.com/gym/100008/ [题目大意] 给出 一个n*m的矩阵,要求用0和1填满,使得每个位置和周围四格相加为偶数,要求1的数目尽量多. [题解 ...

  8. gcc 的include path和lib path调整

    `gcc -print-prog-name=cc1plus` -v `g++ -print-prog-name=cc1plus` -v   ------------------------------ ...

  9. PHP高手干货分享:要大大提高PHP效率

    1.用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双 引号包围的字符串中搜寻变量, 单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的”函数”(译注:PHP ...

  10. [学习笔记]HTML5之canvas

    虐了一下午的canvas 先撸了一个七巧板 <!doctype html> <html> <head> <meta charset="utf-8&q ...