Spring01-准备.jar
1. 准备4+2个jar包
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.log4j-1.2.15(1).jar
spring-beans-4.1.6.RELEASE.jar
spring-context-4.1.6.RELEASE.jar
spring-core-4.1.6.RELEASE.jar
spring-expression-4.1.6.RELEASE.jar
2. 准备.xml文件(applicationContext.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.xsd">
<bean id="someServiceImpl" class="com.caorui.service.impl.SomeServiceImpl"></bean>
</beans>
- http://www.springframework.org/schema/beans/spring-beans.xsd"有时候网络不畅通,影响在xml中写代码的效率,可以在以下设置添加:
![设置的dtd/xsd文件](https://i-blog.csdnimg.cn/blog_migrate/7e911ff2be6310daa79d7b6c41dbb30b.png)
3. 创建service和sevice.impl层和test层
public interface SomeService
void doSome();
}
public class SomeServiceImpl implements SomeService {
public SomeServiceImpl() {
System.out.println("SomeServiceImpl.SomeServiceImpl()");
}
@Override
public void doSome() {
System.out.println("SomeServiceImpl.doSome()");
}
}