# spring-ioc
**Repository Path**: luoyong/spring-ioc
## Basic Information
- **Project Name**: spring-ioc
- **Description**: spring ioc example
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2014-08-27
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
#### pom.xml
``` xml
4.0.0
name.luoyong.spring
spring-ioc
0.0.1-SNAPSHOT
jar
spring-ioc
UTF-8
4.0.3.RELEASE
4.11
junit
junit
${junit.version}
org.springframework
spring-context
${spring.version}
```
#### applicationContext.xml
``` xml
```
#### java test
``` java
package name.luoyong.spring.basic;
import name.luoyong.spring.basic.component.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext.xml");
UserService us = (UserService) ctx.getBean("userService");
us.save();
us.delete();
}
}
```
``` java
package name.luoyong.spring.basic.component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UserService {
@Autowired
// @Qualifier("userDao") // Optional
private UserDao userDao;
public void save() {
userDao.persist();
}
public void delete() {
userDao.remove();
}
}
```
``` java
package name.luoyong.spring.basic.component;
import org.springframework.stereotype.Component;
@Component
public class UserDao {
public void persist() {
System.out.println("do persist User");
}
public void remove() {
System.out.println("do remove User");
}
}
```