![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Spring
种子之家
程序人生,人生程序
展开
-
1.减少spring的配置文件:bean
package com.bjpowernode.spring;public class Bean2 { private Bean3 bean3; private Bean4 bean4; private Bean5 bean5; public Bean3 getBean3() { return bean3; } public void setBean3(Bean3原创 2012-08-29 08:39:18 · 371 阅读 · 0 评论 -
4.减少spring的配置文件:总结
spring的注入1、了解常见属性的注入:int,String,list,set,map的注入2、什么是属性编辑器和作用?* 将spring配置文件中的字符串转换成相应的java对象* spring内置了一些属性编辑器,也可以自定义属性编辑器3、如何自定义属性编辑器?* 继承PropertyEditorSupport* 覆盖setAsText()方法原创 2012-08-29 08:39:43 · 495 阅读 · 0 评论 -
1.spring bean的作用域(是否单例):bean
spring bean的作用域scope取值:* singleton:默认值,每次调用getBean()向IoC容器中取得对象是相同* prototype:每次调用getBean()向IoC容器中取得对象是不相同package com.bjpowernode.spring;public class Bean6 { private String name;原创 2012-08-29 08:39:50 · 413 阅读 · 0 评论 -
3.spring bean的作用域(是否单例):测试
package com.bjpowernode.test;import org.springframework.beans.factory.BeanFactory;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.bjpowernode.spring.Bean1;im原创 2012-08-29 08:40:05 · 416 阅读 · 0 评论 -
2.为什么要是用Spring:manager
package com.bjpowernode.spring.manager;public interface UserManager { public void addUser(String username, String password);}package com.bjpowernode.spring.manager;import com.bjpowernode.sprin原创 2012-08-28 08:34:29 · 497 阅读 · 0 评论 -
3.Spring管理对象:Cient
package com.bjpowernode.spring.client;import org.springframework.beans.factory.BeanFactory;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.bjpowernode.spring.原创 2012-08-28 08:34:54 · 262 阅读 · 0 评论 -
6.Spring管理对象:log4j.properties
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.log4j.rootLogger=INFO, st原创 2012-08-28 08:35:12 · 331 阅读 · 0 评论 -
7.Spring管理对象:IoC
原创 2012-08-28 08:35:18 · 243 阅读 · 0 评论 -
Spring配置default-lazy-init="true"
默认情况下,用到Spring时,Spring用把所有的对象都创建好,并注入好,若是想要到调用的时候才创建或是注入,写上以上配置default-lazy-init="true"原创 2012-08-28 08:35:38 · 610 阅读 · 0 评论 -
1.Spring管理对象:Dao
package com.bjpowernode.spring.dao;public interface UserDao { public void addUser(String username, String password);}package com.bjpowernode.spring.dao;public class UserDao4MySqlImpl implement原创 2012-08-28 08:34:40 · 260 阅读 · 0 评论 -
1.为什么要是用Spring:dao
package com.bjpowernode.spring.dao;public interface UserDao { public void addUser(String username, String password);}package com.bjpowernode.spring.dao;public class UserDao4MySqlImpl implement原创 2012-08-28 08:34:22 · 415 阅读 · 0 评论 -
3.Spring bean常见属性的注入:applicationContext-beans.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http:原创 2012-08-28 08:36:05 · 2986 阅读 · 0 评论 -
2.减少spring的配置文件:applicationContext-common.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http:原创 2012-08-29 08:39:25 · 1843 阅读 · 0 评论 -
3.减少spring的配置文件:测试
package com.bjpowernode.test;import org.springframework.beans.factory.BeanFactory;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.bjpowernode.spring.Bean1;im原创 2012-08-29 08:39:34 · 305 阅读 · 0 评论 -
2.spring bean的作用域(是否单例):applicationContext-beans.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http:原创 2012-08-29 08:39:55 · 916 阅读 · 0 评论 -
1.Spring完成自动装配,两种方式:bean
package com.bjpowernode.spring;public class Bean2 { private Bean3 bean3; private Bean4 bean4; private Bean5 bean5; public Bean3 getBean3() { return bean3; } public void setBean3(Bean3原创 2012-08-29 08:40:13 · 422 阅读 · 0 评论 -
2.Spring完成自动装配,两种方式:applicationContext-common.xml
Spring完成自动装配,两种方式default-autowire="byName"default-autowire="byType"<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"原创 2012-08-29 08:40:20 · 373 阅读 · 0 评论 -
3.Spring完成自动装配,两种方式:测试
package com.bjpowernode.test;import org.springframework.beans.factory.BeanFactory;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.bjpowernode.spring.Bean1;im原创 2012-08-29 08:40:28 · 430 阅读 · 0 评论 -
3.为什么要是用Spring:client
package com.bjpowernode.spring.client;import com.bjpowernode.spring.manager.UserManager;import com.bjpowernode.spring.manager.UserManagerImpl;public class Client { public static void main(Strin原创 2012-08-28 08:34:35 · 299 阅读 · 0 评论 -
多个Spring配置文件时,读取方法
// String[] configLocations = new String[]{"applicationContext.xml",// "applicationContext-editor.xml"};// factory = new ClassPathXmlApplicationContext(configLocations);factory = new ClassPathXmlA原创 2012-08-28 08:35:27 · 404 阅读 · 0 评论 -
2.Spring bean常见属性的注入:属性编辑器,String->java.util.Date
package com.bjpowernode.spring;import java.beans.PropertyEditorSupport;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;/** * java.util.Date属性编辑器 * @aut原创 2012-08-28 08:35:58 · 652 阅读 · 0 评论