Spring再接触 模拟Spring】的更多相关文章

项目分层: 1.最土的方法是直接写到main中去 2.分出model层 2.如下 4.在抽象一个对数据库的访问层(跨数据库实现) 面向抽象编程 User.java package com.bjsxt.model; public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(…
首先更改配置文件 <?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.springframewor…
<bean id="userService" class="com.bjsxt.service.UserService" scope="prototype"> <!-- <property name="userDAO" ref="u" /> --> <constructor-arg> <ref bean="u"/> </c…
直接上例子 引入spring以及Junite所需要的jar包 User.java package com.bjsxt.model; public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = userna…
resource resource beans.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" xmlns:context="http:/…
使用annotation首先得加这两条代码 beans.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" xmlns:context="ht…
Userservice.java package com.bjsxt.service; import com.bjsxt.dao.UserDAO; import com.bjsxt.model.User; public class UserService { private UserDAO userDAO; public void init() { System.out.println("init"); } public void add(User user) { userDAO.sa…
UserDaoImpl package com.bjsxt.dao.impl; import com.bjsxt.dao.UserDAO; import com.bjsxt.model.User; public class UserDAOImpl implements UserDAO { private int daoId; public int getDaoId() { return daoId; } public void setDaoId(int daoId) { this.daoId =…
beans.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.springfr…
<bean name="userDAO" class="com.bjsxt.dao.impl.UserDAOImpl"> <property name="></property> <property name="daoStatus" value="good"></property> </bean> 可以使用上面这种方式将简单类型数据注入到Used…