Skip to content

Commit 4725fe1

Browse files
committed
修改spring配置,不需要扫描Mapper<T>
1 parent 9b4c8a9 commit 4725fe1

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/main/java/com/isea533/mybatis/controller/demo/DemoController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public List<Country> requestTest7(
5454
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
5555
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize
5656
) {
57+
demoService.test();
5758
return demoService.selectPage(pageNum, pageSize);
5859
}
5960
}

src/main/java/com/isea533/mybatis/service/DemoService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
package com.isea533.mybatis.service;
2626

27+
import com.github.abel533.mapper.Mapper;
2728
import com.isea533.mybatis.model.Country;
29+
import org.springframework.beans.factory.annotation.Autowired;
2830
import org.springframework.stereotype.Service;
2931

3032
/**
@@ -33,6 +35,9 @@
3335
@Service
3436
public class DemoService extends BaseService<Country>{
3537

38+
@Autowired
39+
private Mapper<Country> countryMapper;
40+
3641
public int save(Country country) {
3742
if (country == null) {
3843
throw new NullPointerException("保存的对象不能为空!");
@@ -46,4 +51,9 @@ public int save(Country country) {
4651
return super.save(country);
4752
}
4853

54+
public void test(){
55+
int result = countryMapper.selectCount(null);
56+
System.out.println(result);
57+
}
58+
4959
}

src/main/resources/applicationContext.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
<property name="dataSource" ref="dataSource"/>
5858
<property name="mapperLocations">
5959
<array>
60-
<value>classpath*:${mapper.Mapper}</value>
6160
<value>classpath:mapper/*.xml</value>
6261
</array>
6362
</property>

0 commit comments

Comments
 (0)