Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Quartz annotation mode

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to configure Quartz annotations". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure Quartz annotations.

One: directory structure

Two: unified configuration file

Context-datasource.properties

WorkDesk.jdbc.driverclass=com.mysql.jdbc.Driver

WorkDesk.jdbc.url=jdbc:mysql://10.243.3.18:3306/system?userUnicode=true&characterEncoding=UTF-8

WorkDesk.jdbc.username=root

WorkDesk.jdbc.password=$Fortune2015

WorkDesk.jdbc.poolsize.max=3

WorkDesk.jdbc.poolsize.min=3

WorkDesk.jdbc.poolsize.initial=2

WorkDesk.jdbc.idletime.max=25000

WorkDesk.jdbc.idleConnectionTestPeriod=18000

#-workDesk jdbc-

WorkDesk.read.jdbc.driverclass=com.mysql.jdbc.Driver

WorkDesk.read.jdbc.url=jdbc:mysql://10.243.3.18:3306/system?userUnicode=true&characterEncoding=UTF-8

WorkDesk.read.jdbc.username=root

WorkDesk.read.jdbc.password=$Fortune2015

WorkDesk.read.jdbc.poolsize.max=3

WorkDesk.read.jdbc.poolsize.min=3

WorkDesk.read.jdbc.poolsize.initial=2

WorkDesk.read.jdbc.idletime.max=25000

WorkDesk.read.jdbc.idleConnectionTestPeriod=18000

#-redis conf-

Redis.ip=10.243.3.18

Redis.port=6379

Redis.password=$Fortune2015

Redis.default.db=0

Redis.timeout=30000

Redis.pool.maxActive=1024

Redis.pool.maxIdle=200

Redis.pool.maxWait=1000

Redis.pool.testOnBorrow=true

#-jms server-

ActiveMq=failover: (tcp://10.243.3.18:61616,tcp://10.243.3.18:61616)? randomize=false

#-mongodb conf-

Mongodb.host=10.243.3.27

Mongodb.port=27017

Mongodb.database=gmap

Mongodb.username=mongodb

Mongodb.password=$Fortune2016

SystemConfig.properties

Click (here) to collapse or open

# =

# MailSender Config

# =

Mail.host=smtp.mxhichina.com

Three: configuration file

@ Configuration

@ EnableScheduling

@ EnableCaching

@ EnableTransactionManagement (proxyTargetClass = true)

@ ComponentScan ("com.gemdale,com.enjoylink")

@ Import ({DataSourceElConfig.class,TransactionManagerElConfig.class,CachingElConfig.class,MongoElConfig.class,JmsElConfig.class})

Public class AppConfig {

}

@ Configuration

Public class CachingElConfig {

@ Autowired

@ Qualifier ("jedisConnectionFactory")

Private JedisConnectionFactory jedisConnectionFactory

@ Autowired

@ Qualifier ("keySerializer")

Private StringRedisSerializer keySerializer

@ Autowired

@ Qualifier ("valueSerializer")

Private JdkSerializationRedisSerializer valueSerializer

@ Bean (name = "redisTemplate")

Public RedisTemplate redisTemplate () {

RedisTemplate redisTemplate = new RedisTemplate ()

RedisTemplate.setConnectionFactory (jedisConnectionFactory)

RedisTemplate.setKeySerializer (keySerializer)

RedisTemplate.setHashKeySerializer (keySerializer)

RedisTemplate.setValueSerializer (valueSerializer)

RedisTemplate.setHashValueSerializer (valueSerializer)

RedisTemplate.afterPropertiesSet ()

Return redisTemplate

}

@ Bean

Public CacheManager cacheManager (RedisTemplate redisTemplate) {

RedisCacheManager cacheManager = new RedisCacheManager (redisTemplate)

/ / set expiration time

/ / cacheManager.setDefaultExpiration (10)

Return cacheManager

}

}

@ Configuration

@ PropertySource ("classpath:context-datasource.properties")

Public class DataSourceElConfig {

Private static Logger logger = Logger.getLogger (DataSourceElConfig.class)

@ Value ("${workDesk.jdbc.driverclass}")

Private String driverClass

@ Value ("${workDesk.jdbc.url}")

Private String jdbcUrl

@ Value ("${workDesk.jdbc.username}")

Private String user

@ Value ("${workDesk.jdbc.password}")

Private String password

@ Value ("${workDesk.jdbc.poolsize.max}")

Private int maxPoolSize

@ Value ("${workDesk.jdbc.poolsize.min}")

Private int minPoolSize

@ Value ("${workDesk.jdbc.poolsize.initial}")

Private int initialPoolSize

@ Value ("${workDesk.jdbc.idletime.max}")

Private int maxIdleTime

@ Value ("${workDesk.jdbc.idleConnectionTestPeriod}")

Private int idleConnectionTestPeriod

@ Value ("${workDesk.read.jdbc.driverclass}")

Private String readDriverClass

@ Value ("${workDesk.read.jdbc.url}")

Private String readJdbcUrl

@ Value ("${workDesk.read.jdbc.username}")

Private String readUser

@ Value ("${workDesk.read.jdbc.password}")

Private String readPassword

@ Value ("${workDesk.read.jdbc.poolsize.max}")

Private int readMaxPoolSize

@ Value ("${workDesk.read.jdbc.poolsize.min}")

Private int readMinPoolSize

@ Value ("${workDesk.read.jdbc.poolsize.initial}")

Private int readInitialPoolSize

@ Value ("${workDesk.read.jdbc.idletime.max}")

Private int readMaxIdleTime

@ Value ("${workDesk.read.jdbc.idleConnectionTestPeriod}")

Private int readIdleConnectionTestPeriod

@ Value ("${redis.pool.maxActive}")

Private int maxTotal

@ Value ("${redis.pool.maxIdle}")

Private int maxIdle

@ Value ("${redis.pool.maxWait}")

Private long maxWaitMillis

@ Value ("${redis.ip}")

Private String redisIp

@ Value ("${redis.port}")

Private int redisPort

@ Value ("${redis.password}")

Private String redisPassword

@ Value ("${redis.timeout}")

Private int redisTimeout

@ Value ("${redis.default.db}")

Private int redisDb

@ Value ("${mongodb.host}")

Private String mongoHost

@ Value ("${mongodb.port}")

Private int mongoPort

@ Value ("${mongodb.database}")

Private String mongoUserName

@ Value ("${mongodb.username}")

Private String mongoDB

@ Value ("${mongodb.password}")

Private String mongoPassword

@ Value ("${activeMq}")

Private String activeMq

@ Autowired

Private Environment environment

@ Bean

Public static PropertySourcesPlaceholderConfigurer propertyConfigure () {

Return new PropertySourcesPlaceholderConfigurer ()

}

/ * *

* MySql Master write library data source

*

* @ return

, /

@ Bean (name = "platformTomcat", destroyMethod = "close")

Public ComboPooledDataSource platformTomcat () {

ComboPooledDataSource dataSource = new ComboPooledDataSource ()

Try {

DataSource.setDriverClass (driverClass)

}

Catch (PropertyVetoException e) {

Logger.error ("data source configuration, configuration class cannot be found", e)

}

DataSource.setJdbcUrl (jdbcUrl)

DataSource.setUser (user)

DataSource.setPassword (password)

DataSource.setMaxPoolSize (maxPoolSize)

DataSource.setMinPoolSize (minPoolSize)

DataSource.setInitialPoolSize (initialPoolSize)

DataSource.setMaxIdleTime (maxIdleTime)

DataSource.setTestConnectionOnCheckin (true)

DataSource.setPreferredTestQuery ("SELECT 1")

DataSource.setIdleConnectionTestPeriod (idleConnectionTestPeriod)

Return dataSource

}

/ * *

* MySql Slave Reader data Source

*

* @ return

, /

@ Bean (name = "platformReadTomcat", destroyMethod = "close")

Public ComboPooledDataSource platformReadTomcat () {

ComboPooledDataSource dataSource = new ComboPooledDataSource ()

Try {

DataSource.setDriverClass (readDriverClass)

}

Catch (PropertyVetoException e) {

Logger.error ("data source configuration, configuration class cannot be found", e)

}

DataSource.setJdbcUrl (readJdbcUrl)

DataSource.setUser (readUser)

DataSource.setPassword (readPassword)

DataSource.setMaxPoolSize (readMaxPoolSize)

DataSource.setMinPoolSize (readMinPoolSize)

DataSource.setInitialPoolSize (readInitialPoolSize)

DataSource.setMaxIdleTime (readMaxIdleTime)

DataSource.setTestConnectionOnCheckin (true)

DataSource.setPreferredTestQuery ("SELECT 1")

DataSource.setIdleConnectionTestPeriod (readIdleConnectionTestPeriod)

Return dataSource

}

/ * *

* Redis connection pool configuration information

*

* @ return

, /

@ Bean (name = "jedisPoolConfig")

Public JedisPoolConfig jedisPoolConfig () {

JedisPoolConfig jedisPoolConfig = new JedisPoolConfig ()

JedisPoolConfig.setMaxTotal (maxTotal)

JedisPoolConfig.setMaxIdle (maxIdle)

JedisPoolConfig.setMaxWaitMillis (maxWaitMillis)

JedisPoolConfig.setTestOnBorrow (true)

Return jedisPoolConfig

}

@ Bean (name = "jedisConnectionFactory")

Public JedisConnectionFactory jedisConnectionFactory (JedisPoolConfig jedisPoolConfig) {

JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory (jedisPoolConfig)

JedisConnectionFactory.setUsePool (true)

JedisConnectionFactory.setHostName (redisIp)

JedisConnectionFactory.setPort (redisPort)

JedisConnectionFactory.setPassword (redisPassword)

JedisConnectionFactory.setTimeout (redisTimeout)

JedisConnectionFactory.setDatabase (redisDb)

JedisConnectionFactory.afterPropertiesSet ()

Return jedisConnectionFactory

}

@ Bean (name = "keySerializer")

Public StringRedisSerializer keySerializer () {

Return new StringRedisSerializer ()

}

@ Bean (name = "valueSerializer")

Public JdkSerializationRedisSerializer valueSerializer () {

Return new JdkSerializationRedisSerializer ()

}

/ * *

* MongoDB configuration

*

* @ return

, /

@ Bean (name = "mongoDbFactory")

Public MongoDbFactory mongoDbFactory () throws Exception {

MongoCredential credential = MongoCredential.createCredential (mongoUserName, mongoDB

MongoPassword.toCharArray ()

ServerAddress serverAddress = new ServerAddress (mongoHost, mongoPort)

MongoClient mongoClient = new MongoClient (serverAddress, Arrays.asList (credential))

SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory (mongoClient, mongoDB)

Return mongoDbFactory

}

@ Bean (name= "mongoConverter")

Public MongoConverter mongoConverter (MongoDbFactory mongoDbFactory) {

MappingMongoConverter mongoConverter = new MappingMongoConverter (new DefaultDbRefResolver (mongoDbFactory))

New MongoMappingContext ()

/ / do not insert _ class

MongoConverter.setTypeMapper (new DefaultMongoTypeMapper (null))

Return mongoConverter

}

/ * *

* Jms configuration

* @ return

, /

@ Bean (name= "activeMQConnectionFactory")

Public ActiveMQConnectionFactory activeMQConnectionFactory ()

{

ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory ()

ActiveMQConnectionFactory.setUseAsyncSend (false)

ActiveMQConnectionFactory.setBrokerURL (activeMq)

Return activeMQConnectionFactory

}

@ Bean (name= "cachingConnectionFactory")

Public CachingConnectionFactory cachingConnectionFactory (ActiveMQConnectionFactory targetConnectionFactory)

{

CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory (targetConnectionFactory)

CachingConnectionFactory.setSessionCacheSize (10)

Return cachingConnectionFactory

}

}

Click (here) to collapse or open

@ Configuration

@ PropertySource ("classpath:context-datasource.properties")

Public class DataSourceElConfig {

Private static Logger logger = Logger.getLogger (DataSourceElConfig.class)

@ Value ("${workDesk.jdbc.driverclass}")

Private String driverClass

@ Value ("${workDesk.jdbc.url}")

Private String jdbcUrl

@ Value ("${workDesk.jdbc.username}")

Private String user

@ Value ("${workDesk.jdbc.password}")

Private String password

@ Value ("${workDesk.jdbc.poolsize.max}")

Private int maxPoolSize

@ Value ("${workDesk.jdbc.poolsize.min}")

Private int minPoolSize

@ Value ("${workDesk.jdbc.poolsize.initial}")

Private int initialPoolSize

@ Value ("${workDesk.jdbc.idletime.max}")

Private int maxIdleTime

@ Value ("${workDesk.jdbc.idleConnectionTestPeriod}")

Private int idleConnectionTestPeriod

@ Value ("${workDesk.read.jdbc.driverclass}")

Private String readDriverClass

@ Value ("${workDesk.read.jdbc.url}")

Private String readJdbcUrl

@ Value ("${workDesk.read.jdbc.username}")

Private String readUser

@ Value ("${workDesk.read.jdbc.password}")

Private String readPassword

@ Value ("${workDesk.read.jdbc.poolsize.max}")

Private int readMaxPoolSize

@ Value ("${workDesk.read.jdbc.poolsize.min}")

Private int readMinPoolSize

@ Value ("${workDesk.read.jdbc.poolsize.initial}")

Private int readInitialPoolSize

@ Value ("${workDesk.read.jdbc.idletime.max}")

Private int readMaxIdleTime

@ Value ("${workDesk.read.jdbc.idleConnectionTestPeriod}")

Private int readIdleConnectionTestPeriod

@ Value ("${redis.pool.maxActive}")

Private int maxTotal

@ Value ("${redis.pool.maxIdle}")

Private int maxIdle

@ Value ("${redis.pool.maxWait}")

Private long maxWaitMillis

@ Value ("${redis.ip}")

Private String redisIp

@ Value ("${redis.port}")

Private int redisPort

@ Value ("${redis.password}")

Private String redisPassword

@ Value ("${redis.timeout}")

Private int redisTimeout

@ Value ("${redis.default.db}")

Private int redisDb

@ Value ("${mongodb.host}")

Private String mongoHost

@ Value ("${mongodb.port}")

Private int mongoPort

@ Value ("${mongodb.database}")

Private String mongoUserName

@ Value ("${mongodb.username}")

Private String mongoDB

@ Value ("${mongodb.password}")

Private String mongoPassword

@ Value ("${activeMq}")

Private String activeMq

@ Autowired

Private Environment environment

@ Bean

Public static PropertySourcesPlaceholderConfigurer propertyConfigure () {

Return new PropertySourcesPlaceholderConfigurer ()

}

/ * *

* MySql Master write library data source

*

* @ return

, /

@ Bean (name = "platformTomcat", destroyMethod = "close")

Public ComboPooledDataSource platformTomcat () {

ComboPooledDataSource dataSource = new ComboPooledDataSource ()

Try {

DataSource.setDriverClass (driverClass)

}

Catch (PropertyVetoException e) {

Logger.error ("data source configuration, configuration class cannot be found", e)

}

DataSource.setJdbcUrl (jdbcUrl)

DataSource.setUser (user)

DataSource.setPassword (password)

DataSource.setMaxPoolSize (maxPoolSize)

DataSource.setMinPoolSize (minPoolSize)

DataSource.setInitialPoolSize (initialPoolSize)

DataSource.setMaxIdleTime (maxIdleTime)

DataSource.setTestConnectionOnCheckin (true)

DataSource.setPreferredTestQuery ("SELECT 1")

DataSource.setIdleConnectionTestPeriod (idleConnectionTestPeriod)

Return dataSource

}

/ * *

* MySql Slave Reader data Source

*

* @ return

, /

@ Bean (name = "platformReadTomcat", destroyMethod = "close")

Public ComboPooledDataSource platformReadTomcat () {

ComboPooledDataSource dataSource = new ComboPooledDataSource ()

Try {

DataSource.setDriverClass (readDriverClass)

}

Catch (PropertyVetoException e) {

Logger.error ("data source configuration, configuration class cannot be found", e)

}

DataSource.setJdbcUrl (readJdbcUrl)

DataSource.setUser (readUser)

DataSource.setPassword (readPassword)

DataSource.setMaxPoolSize (readMaxPoolSize)

DataSource.setMinPoolSize (readMinPoolSize)

DataSource.setInitialPoolSize (readInitialPoolSize)

DataSource.setMaxIdleTime (readMaxIdleTime)

DataSource.setTestConnectionOnCheckin (true)

DataSource.setPreferredTestQuery ("SELECT 1")

DataSource.setIdleConnectionTestPeriod (readIdleConnectionTestPeriod)

Return dataSource

}

/ * *

* Redis connection pool configuration information

*

* @ return

, /

@ Bean (name = "jedisPoolConfig")

Public JedisPoolConfig jedisPoolConfig () {

JedisPoolConfig jedisPoolConfig = new JedisPoolConfig ()

JedisPoolConfig.setMaxTotal (maxTotal)

JedisPoolConfig.setMaxIdle (maxIdle)

JedisPoolConfig.setMaxWaitMillis (maxWaitMillis)

JedisPoolConfig.setTestOnBorrow (true)

Return jedisPoolConfig

}

@ Bean (name = "jedisConnectionFactory")

Public JedisConnectionFactory jedisConnectionFactory (JedisPoolConfig jedisPoolConfig) {

JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory (jedisPoolConfig)

JedisConnectionFactory.setUsePool (true)

JedisConnectionFactory.setHostName (redisIp)

JedisConnectionFactory.setPort (redisPort)

JedisConnectionFactory.setPassword (redisPassword)

JedisConnectionFactory.setTimeout (redisTimeout)

JedisConnectionFactory.setDatabase (redisDb)

JedisConnectionFactory.afterPropertiesSet ()

Return jedisConnectionFactory

}

@ Bean (name = "keySerializer")

Public StringRedisSerializer keySerializer () {

Return new StringRedisSerializer ()

}

@ Bean (name = "valueSerializer")

Public JdkSerializationRedisSerializer valueSerializer () {

Return new JdkSerializationRedisSerializer ()

}

/ * *

* MongoDB configuration

*

* @ return

, /

@ Bean (name = "mongoDbFactory")

Public MongoDbFactory mongoDbFactory () throws Exception {

MongoCredential credential = MongoCredential.createCredential (mongoUserName, mongoDB

MongoPassword.toCharArray ()

ServerAddress serverAddress = new ServerAddress (mongoHost, mongoPort)

MongoClient mongoClient = new MongoClient (serverAddress, Arrays.asList (credential))

SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory (mongoClient, mongoDB)

Return mongoDbFactory

}

@ Bean (name= "mongoConverter")

Public MongoConverter mongoConverter (MongoDbFactory mongoDbFactory) {

MappingMongoConverter mongoConverter = new MappingMongoConverter (new DefaultDbRefResolver (mongoDbFactory))

New MongoMappingContext ()

/ / do not insert _ class

MongoConverter.setTypeMapper (new DefaultMongoTypeMapper (null))

Return mongoConverter

}

/ * *

* Jms configuration

* @ return

, /

@ Bean (name= "activeMQConnectionFactory")

Public ActiveMQConnectionFactory activeMQConnectionFactory ()

{

ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory ()

ActiveMQConnectionFactory.setUseAsyncSend (false)

ActiveMQConnectionFactory.setBrokerURL (activeMq)

Return activeMQConnectionFactory

}

@ Bean (name= "cachingConnectionFactory")

Public CachingConnectionFactory cachingConnectionFactory (ActiveMQConnectionFactory targetConnectionFactory)

{

CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory (targetConnectionFactory)

CachingConnectionFactory.setSessionCacheSize (10)

Return cachingConnectionFactory

}

}

Click (here) to collapse or open

@ Configuration

Public class JmsElConfig {

@ Autowired

@ Qualifier ("cachingConnectionFactory")

Private CachingConnectionFactory cachingConnectionFactory

@ Bean (name = "jmsTemplate")

Public JmsTemplate jmsTemplate () {

JmsTemplate jmsTemplate = new JmsTemplate ()

JmsTemplate.setConnectionFactory (cachingConnectionFactory)

Return jmsTemplate

}

@ Bean (name = "serviceDemoDestination")

Public Destination serviceDemoDestination () {

ActiveMQQueue serviceDemoQueue = new ActiveMQQueue ("serviceDemoQueue")

Return serviceDemoQueue

}

@ Bean (name = "jmsListenerContainerFactory")

Public JmsListenerContainerFactory jmsListenerContainerFactory () {

DefaultJmsListenerContainerFactory jmsListenerContainerFactory = new DefaultJmsListenerContainerFactory ()

JmsListenerContainerFactory.setConnectionFactory (cachingConnectionFactory)

Return jmsListenerContainerFactory

}

}

Click (here) to collapse or open

@ Configuration

Public class MongoElConfig {

@ Autowired

@ Qualifier ("mongoDbFactory")

Private MongoDbFactory mongoDbFactory

@ Autowired

@ Qualifier ("mongoConverter")

Private MongoConverter mongoConverter

@ Bean (name = "mongoTemplate")

Public MongoTemplate mongoTemplate () {

MongoTemplate mongoTemplate = new MongoTemplate (mongoDbFactory, mongoConverter)

Return mongoTemplate

}

}

Click (here) to collapse or open

@ Configuration

@ PropertySource ("classpath:systemConfig.properties")

Public class SystemElConfig {

@ Value ("${mail.host}")

Private String mailHost

@ Autowired

Private Environment environment

@ Bean

Public static PropertySourcesPlaceholderConfigurer propertyConfigure () {

Return new PropertySourcesPlaceholderConfigurer ()

}

/ * *

* @ return the mailHost

, /

Public String getMailHost () {

Return mailHost

}

/ * *

* @ param mailHost

* the mailHost to set

, /

Public void setMailHost (String mailHost) {

This.mailHost = mailHost

}

}

Click (here) to collapse or open

@ Configuration

@ PropertySource ("classpath:systemConfig.properties")

Public class SystemElConfig {

@ Value ("${mail.host}")

Private String mailHost

@ Autowired

Private Environment environment

@ Bean

Public static PropertySourcesPlaceholderConfigurer propertyConfigure () {

Return new PropertySourcesPlaceholderConfigurer ()

}

/ * *

* @ return the mailHost

, /

Public String getMailHost () {

Return mailHost

}

/ * *

* @ param mailHost

* the mailHost to set

, /

Public void setMailHost (String mailHost) {

This.mailHost = mailHost

}

}

Click (here) to collapse or open

@ Configuration

Public class TransactionManagerElConfig {

@ Autowired

@ Qualifier ("platformTomcat")

Private DataSource platformTomcat

@ Autowired

@ Qualifier ("platformReadTomcat")

Private DataSource platformReadTomcat

@ Bean (name = "jdbcTemplate")

Public JdbcTemplate jdbcTemplate () {

JdbcTemplate jdbcTemplate = new JdbcTemplate ()

JdbcTemplate.setDataSource (platformTomcat)

Return jdbcTemplate

}

@ Bean (name = "jdbcReadTemplate")

Public JdbcTemplate jdbcReadTemplate () {

JdbcTemplate jdbcReadTemplate = new JdbcTemplate ()

JdbcReadTemplate.setDataSource (platformReadTomcat)

Return jdbcReadTemplate

}

@ Bean (name = "transactionManager")

Public DataSourceTransactionManager transactionManager () {

DataSourceTransactionManager transactionManager = new DataSourceTransactionManager ()

TransactionManager.setDataSource (platformTomcat)

Return transactionManager

}

}

Four: Demo

Click (here) to collapse or open

Public class App {

Public static void main (String [] args) {

AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (AppConfig.class)

System.out.println (null = = context.getBean ("platformTomcat"))

System.out.println (null = = context.getBean ("transactionManager"))

System.out.println (null = = context.getBean ("redisTemplate"))

System.out.println (null = = context.getBean ("mongoTemplate"))

System.out.println (null = = context.getBean ("jmsTemplate"))

System.out.println (context.getBean (SystemElConfig.class). GetMailHost ()

Context.getBean (ServiceDemo.class) .print ()

}

}

Click (here) to collapse or open

@ Service

Public class ServiceDemo {

@ Value ("# {systemElConfig.mailHost}")

Private String mailHost

Public void print () {

System.out.println ("=" + mailHost)

}

}

Click (here) to collapse or open

@ Service

Public class ServiceDemo {

@ Value ("# {systemElConfig.mailHost}")

Private String mailHost

Public void print () {

System.out.println ("=" + mailHost)

}

}

Click (here) to collapse or open

@ Service

Public class ServiceDemo {

@ Value ("# {systemElConfig.mailHost}")

Private String mailHost

Public void print () {

System.out.println ("=" + mailHost)

}

}

Click (here) to collapse or open

@ Component

@ EnableJms

Public class ServiceDemoListener extends AbstractListener {

@ JmsListener (containerFactory = "jmsListenerContainerFactory", destination = "serviceDemoQueue")

Public void onMessage (Message message) {

Try {

If (message instanceof ObjectMessage) {

}

}

Catch (Exception e) {

Logger.error ("message handling exception", e)

}

}

}

Click (here) to collapse or open

@ Component

@ EnableJms

Public class ServiceDemoListener extends AbstractListener {

@ JmsListener (containerFactory = "jmsListenerContainerFactory", destination = "serviceDemoQueue")

Public void onMessage (Message message) {

Try {

If (message instanceof ObjectMessage) {

}

}

Catch (Exception e) {

Logger.error ("message handling exception", e)

}

}

}

Click (here) to collapse or open

@ Component

Public class ServiceDemoSchedule {

@ Autowired

Private GmcSmsInfoBo gmcSmsInfoBo

@ Scheduled (cron = "0 *?")

Public void work () {

System.out.println ("= Good bytecodes =")

GmcSmsInfo smsInfo = new GmcSmsInfo ()

SmsInfo.setChannel ("test")

SmsInfo.setContent ("test")

SmsInfo.setStatus ("01")

SmsInfo.setCreateDate (Calendar.getInstance () .getTime ())

SmsInfo.setMobile ("9999999999999")

Try {

GmcSmsInfoBo.add (smsInfo)

System.out.println (null==gmcSmsInfoBo.query (11386))

System.out.println (null==gmcSmsInfoBo.query (11401))

}

Catch (BusinessServiceException e) {

E.printStackTrace ()

}

}

}

@ Service ("gmcSmsInfoBo")

Public class GmcSmsInfoBo extends AbstractBusinessObject {

@ Autowired

Private GmcSmsInfoDAO gmcSmsInfoDaoImpl

@ CachePut (value = "GmcSmsInfoCache", key = "'GmcSmsInfo_'+#result.smsId")

@ Transactional (rollbackFor= {Exception.class,RuntimeException.class})

Public GmcSmsInfo add (GmcSmsInfo smsInfo) throws BusinessServiceException {

System.out.println ("= add=")

Try {

SmsInfo.setSmsId (gmcSmsInfoDaoImpl.save (smsInfo))

}

Catch (FrameworkDAOException e) {

Throw new BusinessServiceException (e)

}

Return smsInfo

}

@ Cacheable (value= "GmcSmsInfoCache", key= "'GmcSmsInfo_'+#smsId")

Public GmcSmsInfo query (Integer smsId) throws BusinessServiceException {

System.out.println ("= query=")

Try {

Return gmcSmsInfoDaoImpl.findById (GmcSmsInfo.class, smsId)

}

Catch (Exception e) {

Throw new BusinessServiceException (e)

}

}

}

At this point, I believe you have a deeper understanding of "how to configure Quartz annotations". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report