# my-ssm
**Repository Path**: xwz-git/my-ssm
## Basic Information
- **Project Name**: my-ssm
- **Description**: ssm整合项目
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-01-06
- **Last Updated**: 2021-01-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# SSM 整合
## 先Mybatis整合Spring、
- 添加pojo、mapper、service代码
- 添加spring配置文件`applicationContext.xml`
```xml
```
- 编写测试方法AccountServiceImplTest
```java
@RunWith(SpringJUnit4ClassRunner.class)
// 测试需要配置注解来扫描指定配置,才能使用spring的注解来注入属性
@ContextConfiguration(locations = {"classpath*:application*.xml"})
public class AccountServiceImplTest {
// 从ioc容器中 注入属性
@Autowired
private AccountService accountService;
@Test
public void queryAccountList() throws Exception {
List accounts = accountService.queryAccountList();
System.out.println(accounts);
}
}
```
## 再整合SpringMVC
web.xml添加配置
```xml
contextConfigLocation
classpath*:applicationContext*.xml
org.springframework.web.context.ContextLoaderListener
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:springmvc.xml
springmvc
/
```
- 添加配置springmvc.xml
```xml
```
## 附件
sql语句
```sql
-- ----------------------------
-- Table structure for account
-- ----------------------------
DROP TABLE IF EXISTS `account`;
CREATE TABLE `account` (
`cardNo` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NOT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL,
`money` decimal(10, 0) NULL DEFAULT NULL,
PRIMARY KEY (`cardNo`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_croatian_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of account
-- ----------------------------
INSERT INTO `account` VALUES ('6029621011000', '韩梅梅', 9900);
INSERT INTO `account` VALUES ('6029621011001', '李大雷', 10100);
```