服务层的配置发布服务 taotao-manager-dao、taotao-manager-interface、taotao-manager-service
TestMapper.java
package com.taotao.mapper; /** * 测试接口,查询当前的时间 */ public interface TestMapper { public String queryNow(); }
TestMapper.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.taotao.mapper.TestMapper"> <select id="queryNow" resultType="string"> select NOW() </select> </mapper>
TestService.java
package com.taotao.service; /** * 测试 接口 查询当前时间 */ public interface TestService { //查询当前的时间 public String queryNow(); }
TestServiceImpl.java
package com.taotao.service.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.taotao.mapper.TestMapper; import com.taotao.service.TestService; @Service public class TestServiceImpl implements TestService { @Autowired private TestMapper mapper; @Override public String queryNow() { //1.注入mapper //2.调用mapper的方法 返回 return mapper.queryNow(); } }
https://github.com/godmaybelieve