- 浏览: 84650 次
- 性别:
- 来自: 广州
文章分类
最新评论
spring启动时应用不需要加载数据库,需要时在加载,如何实现?
2010-10-22 11:22 提问者悬赏:15分 |zxqwh| 分类:其他编程语言 | 浏览1195次
也就是说应用启动时不连接数据库,其它不使用数据库的应用也能启动,当用到数据库操作的应用需要操作数据库时,在加载数据库,怎么实现,我说情况和hibernate的延迟加载是不一样的,我是用的是spring+hibernate实现DAO的开发模式。 你的回答好像没有理解我的意思,说的其实好像不是这样实现,我的业务需求是开始时不连接数据库,等用到数据库时在做相应的操作,相当于动态的加载数据库,你说的延迟加载时加载完了,获取对象时候的事了。
<beans>加一个属性:<beans default-lazy-init="true">
就会导致Spring在启动的时候不加载数据库.
但是不要每个applicationContext-xxx.xml文件都加这个。只是在需要延迟加载的文件里面写上这段。
2010-10-22 11:22 提问者悬赏:15分 |zxqwh| 分类:其他编程语言 | 浏览1195次
也就是说应用启动时不连接数据库,其它不使用数据库的应用也能启动,当用到数据库操作的应用需要操作数据库时,在加载数据库,怎么实现,我说情况和hibernate的延迟加载是不一样的,我是用的是spring+hibernate实现DAO的开发模式。 你的回答好像没有理解我的意思,说的其实好像不是这样实现,我的业务需求是开始时不连接数据库,等用到数据库时在做相应的操作,相当于动态的加载数据库,你说的延迟加载时加载完了,获取对象时候的事了。
<beans>加一个属性:<beans default-lazy-init="true">
就会导致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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd" default-lazy-init="true">
但是不要每个applicationContext-xxx.xml文件都加这个。只是在需要延迟加载的文件里面写上这段。
2014-3-28 14:24:02 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_34\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.6.0_34\jre\bin;C:/Program Files/Java/jdk1.6.0_34/bin/../jre/bin/server;C:/Program Files/Java/jdk1.6.0_34/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_34/bin/../jre/lib/amd64;E:\Oracle11gR2\Administrator\product\11.2.0\dbhome_1\bin;.;C:\Program Files\Java\jdk1.6.0_34\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;D:\tools\apache-maven-2.2.1\bin;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Common Files\Easysoft\Shared\;C:\Program Files\Common Files\Easysoft\Shared\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;E:\Microsoft SQL Server\Shared\100\Tools\Binn\;E:\Microsoft SQL Server\Shared\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;D:\sqluldr64;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;D:\Program Files (x86);D:\eclipse;;. 2014-3-28 14:24:02 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:wxsc' did not find a matching property. 2014-3-28 14:24:02 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-8989 2014-3-28 14:24:02 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 569 ms 2014-3-28 14:24:02 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2014-3-28 14:24:02 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.36 2014-3-28 14:24:03 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2014-03-28 14:24:03,366 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization started 2014-03-28 14:24:03,408 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@40c07527: display name [Root WebApplicationContext]; startup date [Fri Mar 28 14:24:03 CST 2014]; root of context hierarchy 2014-03-28 14:24:03,496 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from URL [file:/H:/project249/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/wxsc/WEB-INF/classes/applicationContext.xml] 2014-03-28 14:24:04,135 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from URL [file:/H:/project249/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/wxsc/WEB-INF/classes/applicationContext-persist.xml] 2014-03-28 14:24:04,157 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from URL [file:/H:/project249/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/wxsc/WEB-INF/classes/applicationContext-service.xml] 2014-03-28 14:24:04,176 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from URL [file:/H:/project249/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/wxsc/WEB-INF/classes/applicationContext-service-liuhaihui.xml] 2014-03-28 14:24:04,200 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@40c07527]: org.springframework.beans.factory.support.DefaultListableBeanFactory@bc22eb 2014-03-28 14:24:04,301 INFO [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] - Loading properties file from class path resource [jdbc.properties] 2014-03-28 14:24:04,353 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@bc22eb: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,pabpp,cabpp,dataSource,entityManagerFactory,transactionManager,javaMailSender,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,managerTx,validateService,deleteToolService,request.musicMessageHandler,request.newsMessageHandler,request.textMessageHandler,request.voiceMessageHandler,serverNumMessageHandlerChain,serverNumberMenuService,subscribeNumberMenuService,dataAnalysisService]; root of factory hierarchy 2014-03-28 14:24:04,422 INFO [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 1055 ms 2014-03-28 14:24:04,551 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml] 2014-03-28 14:24:04,665 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml] 2014-03-28 14:24:04,691 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Unable to locate configuration files of the name struts.xml, skipping 2014-03-28 14:24:04,691 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml] 2014-03-28 14:24:04,699 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from applicationMessage 2014-03-28 14:24:04,799 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration... 2014-03-28 14:24:04,799 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name 2014-03-28 14:24:04,800 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully 2014-03-28 14:24:05,659 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml] 2014-03-28 14:24:05,696 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml] 2014-03-28 14:24:05,698 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Unable to locate configuration files of the name struts.xml, skipping 2014-03-28 14:24:05,698 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml] 2014-03-28 14:24:05,702 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from applicationMessage 2014-03-28 14:24:05,712 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration... 2014-03-28 14:24:05,712 INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name 2014-03-28 14:24:05,713 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully 2014-3-28 14:24:05 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8989 2014-3-28 14:24:06 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2014-3-28 14:24:06 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/19 config=null 2014-3-28 14:24:06 org.apache.catalina.startup.Catalina start 信息: Server startup in 3512 ms 2014-03-28 14:24:23,813 INFO [com.mchange.v2.log.MLog] - MLog clients using log4j logging. 2014-03-28 14:24:23,899 INFO [com.mchange.v2.c3p0.C3P0Registry] - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10] 2014-03-28 14:24:24,054 INFO [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] - Building JPA container EntityManagerFactory for persistence unit 'AppProductPersistenceUnit' 2014-03-28 14:24:24,095 INFO [org.hibernate.cfg.annotations.Version] - Hibernate Annotations 3.4.0.GA 2014-03-28 14:24:24,111 INFO [org.hibernate.cfg.Environment] - Hibernate 3.3.2.GA 2014-03-28 14:24:24,113 INFO [org.hibernate.cfg.Environment] - hibernate.properties not found 2014-03-28 14:24:24,116 INFO [org.hibernate.cfg.Environment] - Bytecode provider name : javassist 2014-03-28 14:24:24,121 INFO [org.hibernate.cfg.Environment] - using JDK 1.4 java.sql.Timestamp handling 2014-03-28 14:24:24,208 INFO [org.hibernate.annotations.common.Version] - Hibernate Commons Annotations 3.1.0.GA 2014-03-28 14:24:24,212 INFO [org.hibernate.ejb.Version] - Hibernate EntityManager 3.4.0.GA 2014-03-28 14:24:24,234 INFO [org.hibernate.ejb.Ejb3Configuration] - Processing PersistenceUnitInfo [ name: AppProductPersistenceUnit ...] 2014-03-28 14:24:24,436 INFO [org.hibernate.cfg.AnnotationBinder] - Binding entity from annotated class: com.kington.wxsc.model.db.OrderStatistic 2014-03-28 14:24:24,472 INFO [org.hibernate.cfg.annotations.EntityBinder] - Bind entity com.kington.wxsc.model.db.OrderStatistic on table wxsc_order_statistics 2014-03-28 14:24:24,537 INFO [org.hibernate.cfg.AnnotationConfiguration] - Hibernate Validator not found: ignoring 2014-03-28 14:24:24,560 INFO [org.hibernate.cfg.search.HibernateSearchEventListenerRegister] - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 2014-03-28 14:24:24,607 INFO [org.hibernate.connection.ConnectionProviderFactory] - Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider 2014-03-28 14:24:24,610 INFO [org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider] - Using provided datasource 2014-03-28 14:24:24,665 INFO [com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource] - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1b60udb9121ivj6qczq01|5fbd7d0e, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1b60udb9121ivj6qczq01|5fbd7d0e, idleConnectionTestPeriod -> 0, initialPoolSize -> 2, jdbcUrl -> jdbc:mysql://localhost:3306/wxsc?useUnicode=true&characterEncoding=UTF-8, lastAcquisitionFailureDefaultUser -> null, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 3, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ] 2014-03-28 14:24:24,790 INFO [org.hibernate.cfg.SettingsFactory] - RDBMS: MySQL, version: 5.1.41-community 2014-03-28 14:24:24,790 INFO [org.hibernate.cfg.SettingsFactory] - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.4 ( $Date: 2006-10-19 17:47:48 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ ) 2014-03-28 14:24:24,812 INFO [org.hibernate.dialect.Dialect] - Using dialect: org.hibernate.dialect.MySQLDialect 2014-03-28 14:24:24,817 INFO [org.hibernate.transaction.TransactionFactoryFactory] - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory 2014-03-28 14:24:24,818 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2014-03-28 14:24:24,818 INFO [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled 2014-03-28 14:24:24,819 INFO [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled 2014-03-28 14:24:24,819 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch size: 15 2014-03-28 14:24:24,819 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch updates for versioned data: disabled 2014-03-28 14:24:24,819 INFO [org.hibernate.cfg.SettingsFactory] - Scrollable result sets: enabled 2014-03-28 14:24:24,820 INFO [org.hibernate.cfg.SettingsFactory] - JDBC3 getGeneratedKeys(): enabled 2014-03-28 14:24:24,820 INFO [org.hibernate.cfg.SettingsFactory] - Connection release mode: auto 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Maximum outer join fetch depth: 3 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Default batch fetch size: 1 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Generate SQL with comments: enabled 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Order SQL updates by primary key: disabled 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Order SQL inserts for batching: disabled 2014-03-28 14:24:24,821 INFO [org.hibernate.cfg.SettingsFactory] - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2014-03-28 14:24:24,823 INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - Using ASTQueryTranslatorFactory 2014-03-28 14:24:24,823 INFO [org.hibernate.cfg.SettingsFactory] - Query language substitutions: {} 2014-03-28 14:24:24,823 INFO [org.hibernate.cfg.SettingsFactory] - JPA-QL strict compliance: enabled 2014-03-28 14:24:24,823 INFO [org.hibernate.cfg.SettingsFactory] - Second-level cache: enabled 2014-03-28 14:24:24,823 INFO [org.hibernate.cfg.SettingsFactory] - Query cache: disabled 2014-03-28 14:24:24,823 INFO [org.hibernate.cfg.SettingsFactory] - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2014-03-28 14:24:24,824 INFO [org.hibernate.cfg.SettingsFactory] - Optimize cache for minimal puts: disabled 2014-03-28 14:24:24,824 INFO [org.hibernate.cfg.SettingsFactory] - Structured second-level cache entries: disabled 2014-03-28 14:24:24,828 INFO [org.hibernate.cfg.SettingsFactory] - Echoing all SQL to stdout 2014-03-28 14:24:24,828 INFO [org.hibernate.cfg.SettingsFactory] - Statistics: enabled 2014-03-28 14:24:24,828 INFO [org.hibernate.cfg.SettingsFactory] - Deleted entity synthetic identifier rollback: disabled 2014-03-28 14:24:24,829 INFO [org.hibernate.cfg.SettingsFactory] - Default entity-mode: pojo 2014-03-28 14:24:24,829 INFO [org.hibernate.cfg.SettingsFactory] - Named query checking : enabled 2014-03-28 14:24:24,859 INFO [org.hibernate.impl.SessionFactoryImpl] - building session factory 2014-03-28 14:24:25,014 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Not binding factory to JNDI, no JNDI name configured 2014-03-28 14:24:25,025 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - Running hbm2ddl schema update 2014-03-28 14:24:25,025 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - fetching database metadata 2014-03-28 14:24:25,030 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - updating schema 2014-03-28 14:24:25,064 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - table found: wxsc.wxsc_order_statistics 2014-03-28 14:24:25,064 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - columns: [delivery_time, delivery_type, gift, value_added_tax_invoice, order_quantity, updatetime, product_id, product_attribute, consignee, invoice, product_name, total_sum, express_type, remarks, order_system_category, express_number, unit_price, version, invoice_content, invoice_type, createtime, id, order_amount, account_payable, place_order_account_number, order_time, customer_payment_term, seller_remarks, payment_confirm_time, order_remarks, order_date, store_name, order_number, customer_address, consignee_telephone_number, customer_name, balance_payment, freight_amount, order_status, post_invoice, article_number, customer_telephone_number, consignee_address, invoice_head, customer_id, order_type] 2014-03-28 14:24:25,064 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - foreign keys: [] 2014-03-28 14:24:25,064 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] - indexes: [primary] 2014-03-28 14:24:25,064 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] - schema update complete
发表评论
-
记录一下我的p2p的UDP打洞过程【云服务器公网版本】
2014-07-19 21:14 2156服务端连接了成功处理了两个客户端的登录并且成功打洞后的log记 ... -
记录一下我的p2p的UDP打洞过程【localhost局域网版本】
2014-07-19 21:08 2046MainServer在两个客户端都启动成功之后并且打洞成功之后 ... -
有hadoop_zookeeper的pom.xml
2014-06-03 23:39 862FROM:http://blog.csdn.net/zph2 ... -
省市县三级联动数据库
2014-06-03 09:42 3219/* *@名称: myaddress.js ... -
Java中的注解机制--比较详细
2014-05-31 17:33 590http://blog.csdn.net/a243932069 ... -
记录一下这次mvn 淘宝的开源MVC框架 Webx的过程
2014-05-24 21:44 850[INFO] ------------------ ... -
恶心的Enum类型
2014-05-24 09:59 698public enum InvoiceType { ... -
分页标签<w:pager>
2014-05-09 17:05 10061.WEB-INF/tlds/pager.tld < ... -
自定义标签taglib
2014-05-09 17:00 751JSP 最佳实践: taglib简介 ... -
MyEclipse has detected that less than 5% of the 31MB of Eden Space (Heap memory)
2014-04-27 12:48 1082解决办法: D:\>cd D:\Users\Admin ... -
数据库映射只@OneToMany的两个区别
2014-03-31 21:07 812========================== (不加 ... -
接着报错,连接问题Cannot open a connection
2014-03-28 18:39 1402HTTP Status 500 - ------- ... -
异常的Tomcat输出信息-修正log4j配置文件之后仍然异常
2014-03-28 11:51 10892014-3-28 11:46:50 org.apache ... -
异常的Tomcat输出信息
2014-03-28 11:27 696正常情况下是没有换行的。现在异常的情况是有换行的。 20 ... -
正常的Tomcat输出信息
2014-03-28 11:26 10052014-3-28 11:23:07 org.apache ... -
烦人的后台首页index.jsp弄好了
2014-03-25 14:39 46071.<title>微信公众平台后台管理< ... -
MAVEN官网地址
2014-03-25 10:12 724http://mvnrepository.com/artifa ... -
正则表达式
2014-03-25 10:11 553[正则表达式]文本框输入内容控制 整数或者小数:^[0-9]+ ... -
Window 通过cmd查看端口占用、相应进程、杀死进程等的命令
2014-03-24 16:03 1061Window 通过cmd查看端口占用、相应进程、杀死进程等的命 ... -
java synchronized详解
2014-03-16 11:30 472Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候 ...
相关推荐
lazy-init参数的优先级高于default-lazy-init参数,这意味着如果Bean的lazy-init参数为true,即使default-lazy-init参数为false,Bean也不会在Spring容器启动时实例化。 三、abstract参数 abstract参数也是Bean...
我的博客中“maven环境搭建及Spring入门”的项目代码。在idea中运行成功。 1。创建IOC容器 2。通过xml装配对象 【简单类型用value、复杂(引用类型)用ref、数组,集合,Map的装配】 ...default-lazy-init=true
在Spring中配置一个bean为延迟实例化非常简单,只需要在`<bean>`元素中添加`lazy-init`属性并设置其值为`true`即可。例如: ```xml <bean id="lazyBean" class="com.example.LazyBean" lazy-init="true"> <!-- ...
-- 关于spring启动的优化 default-lazy-init="true" --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> ...
解决这个问题的方法是启用Spring的懒加载特性(default-lazy-init=true)。这样,只有在真正需要用到bean时才会进行实例化,显著降低了启动时间。在实际案例中,这个简单的改动就将启动时间从55秒降低到了8秒,极大...
接着,需要在`web.xml`文件中配置Spring的监听器,以便于启动时加载Spring的上下文。 ```xml <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> ``` 另外,还需要定义...
- **Default Lazy Initialization**:若希望对所有 Bean 都应用懒加载,则可以在 `<beans>` 根节点中设置 `default-lazy-init="true"`。 - **初始化和销毁方法**:可以指定初始化和销毁方法来管理 Bean 的生命周期...
- `default-lazy-init`:如果设置为true,所有Bean默认为懒加载,否则默认立即初始化。 - `default-autowire`:设定容器的自动装配策略,默认为"no",表示不进行自动装配。 - `default-init-method`和`default-...
- **懒加载**:通过`lazy-init="true"`属性可以控制Bean的初始化时机。 - **条件化扫描**:结合`@Conditional`注解,根据运行时环境条件决定是否扫描和注册Bean。 #### 结论 `<context:component-scan/>`是Spring ...
default-lazy-init="false" default-autowire="byName"> <context:annotation-config/> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value=...
default-lazy-init="true"> <!-- 配置PropertyPlaceholderConfigurer以读取jdbc.properties --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config....
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" default-lazy-init="true"> <property name="triggers"> ``` 3. **动态更新 Trigger**:通过获取 Scheduler ...
- `default-lazy-init="true"`表示默认情况下Bean的实例化采用懒加载方式。 ```xml <!-- 源Bean提供Hibernate session factory --> <bean id="dataSource" class="..."> <!-- 数据源配置省略 --> <bean id=...
在Spring配置文件中,如果设置了`default-lazy-init="true"`,则所有未明确设置为非懒加载的Bean都会采用懒加载模式。这意味着在Spring容器启动时不会立即初始化这些Bean,而是在第一次调用它们时才进行初始化。 ##...
如果设为`true`,则Bean只有在真正被请求时才会被实例化,这可以优化应用启动时间,特别是当有大量Bean时。 接下来,我们关注`<bean>`元素,它是Spring配置中最常用的元素,用于定义单个Bean: 1. `id`和`name`: `...
default-lazy-init="true" default-autowire="byName"> <!-- 启用AspectJ自动代理 --> <aop:aspectj-autoproxy/> <!-- 配置切面类 --> <bean class="com.incon.framework.aop.Aop"/> ``` ### 实现 2. 接...
* lazy-init为“default/false”当启动spring容器的时候创建bean 但是如果该bean是prototype时,特殊。这种情况无效 * 在spring容器启动的时候,就会发现错误 * 有可能会造成一些数据长时间驻留在内存中 * lazy...