分模块开发创建service子模块——(八)

1.右击父工程新建maven子模块

 

2.填写模块名字

 

 

3.添加service模块代码与配置文件(出错是因为依赖dao层,4解决)

4.添加dao依赖

(1)更新索引

 

(2)添加dao依赖

结果:(如果dao项目为关闭是个文件夹)

5.junit测试:(添加junit包)

 

6.测试代码

 1 package cn.qlq.service.impl;
 2 
 3 import static org.junit.Assert.*;
 4 
 5 import org.junit.Test;
 6 import org.junit.runner.RunWith;
 7 import org.springframework.beans.factory.annotation.Autowired;
 8 import org.springframework.test.context.ContextConfiguration;
 9 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 
11 import cn.qlq.service.UserService;
12 
13 //第一种写法
14 @ContextConfiguration(locations={"classpath:applicationContext-service.xml","classpath:applicationContext-dao.xml"})
15 //第二种写法
16 //@ContextConfiguration("classpath*:applicationContext-*.xml")
17 @RunWith(SpringJUnit4ClassRunner.class)
18 public class UserServiceImplTest {
19 
20     @Autowired
21     private UserService userService;
22 
23     @Test
24     public void test() throws Exception {
25         System.out.println(userService.findUserById(1));
26     }
27 
28 }

 

结果:

 

 7.发布到本地仓库

 

结果:

8.查看本地仓库

9.依赖范围对依赖传递的影响

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值