Java?????spring ???????
???????????? ???????[ 2015/5/6 13:28:32 ] ????????????????
?????????????bean.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- ????????? -->
<bean id="user" class="com.bjsxt.model.User" >
<constructor-arg index="0" type="String" value="zhou"></constructor-arg>
<constructor-arg index="1" type="String" value="password"></constructor-arg>
</bean>
<!-- ??????? -->
<bean id="user1" class="com.bjsxt.model.User" >
<property name="username" value="zhang"></property>
<property name="password" value="oumyye"></property>
</bean>
<!-- ??????? -->
<bean id= "userFactory" class="com.bjsxt.factory.UserFactory" > </bean>
<bean id="user2" factory-bean="userFactory" factory-method="CreatUser"></bean>
<!-- ?????????? -->
<bean id= "user3" class="com.bjsxt.factory.UserFactory2" factory-method="CreatUser"> </bean>
<bean id="u" class="com.bjsxt.dao.impl.UserDAOImpl"></bean>
<bean id="userService" class="com.bjsxt.service.UserService" init-method="init" destroy-method="destroy" scope="prototype">
<!-- <property name="userDAO" ref="u" /> -->
<!-- ????????? -->
<constructor-arg>
<ref bean="u"/>
</constructor-arg>
</bean>
</beans>
??????????
package com.bjsxt.service;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.bjsxt.model.User;
public class UserServiceTest {
@Test
public void test() {
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("beans.xml");
UserService userService=(UserService) applicationContext.getBean("userService");
//?????????
User user=(User) applicationContext.getBean("user");
//???????
User user1=(User) applicationContext.getBean("user1");
//???????
User user2=(User) applicationContext.getBean("user2");
//???????
User user3=(User) applicationContext.getBean("user3");
System.out.println(user);
System.out.println(user1);
System.out.println(user2);
System.out.println(user3);
userService.save(user);
userService.destroy();
}
}
?????????
????###########init
????User [username=zhou?? password=password]
????User [username=zhang?? password=oumyye]
????User [username=??1?? password=oumyye]
????User [username=?my?1?? password=oumyye]
????user saved!
????destroy
????????????????????
???????????—??????
????Spring??????????????????????????????????????в????????????????????????????δ?????????????????????????????
???????????????????????????????£?
????<bean id="***" class="***" autowire="byType">
???????????????autowire???????????????????????????????д<property>???????????л?????????????????setter??????
????Autowire??????????????????
????· byType ????????? ????????????????????????????????????bean?????ж?????????????????????????????????null??
????· byName ????????? ???????????????????????в??????????????????bean?????????????????????null??
????· constructor ??byType?????????????????????????????????????????????????????????????????????μ?bean??????????????
????· autodetect ???bean??????????(introspection)???????????constructor????byType????????????????????????????????????????byType??????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????