zoukankan      html  css  js  c++  java
  • 通用后台管理系统(3)测试环境是否成功

    1、生成mapper pojo

    使用 generatorSqlmapCustom生成

    2、编写接口类

    package com.sundablog.service;
    
    import java.util.List;
    
    import com.sundablog.pojo.AdminUser;
    
    public interface TestService {
    	/**
    	 * 查询全部管理员
    	 * @Title: selectAdmin   
    	 * @Description: TODO(这里用一句话描述这个方法的作用)   
    	 * @param: @return      
    	 * @return: List<AdminUser>      
    	 * @throws
    	 */
    	List<AdminUser> selectAdmin();
    }	
    
    

    3、编写接口类

    package com.sundablog.service.impl;
    
    import java.util.List;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import com.sundablog.mapper.AdminUserMapper;
    import com.sundablog.pojo.AdminUser;
    import com.sundablog.pojo.AdminUserExample;
    import com.sundablog.service.TestService;
    
    @Service
    public class TestServiceImpl implements TestService {
    
    	@Autowired
    	private AdminUserMapper adminUserMapper;
    	
    	@Override
    	public List<AdminUser> selectAdmin() {
    		AdminUserExample example = new AdminUserExample();
    		List<AdminUser> list = adminUserMapper.selectByExample(example);
    		return list;
    	}
    }
    

    4、设置dubbo暴露的服务接口

    在backend-server-rpc中 applicationContext-service.xml 添加一条xml

    <dubbo:service interface="com.sundablog.service.TestService" ref="testServiceImpl" version="1.0.0" />
    

    5、引用dubbo服务

    在backend-server-web中 applicationContext-dubbo.xml 添加一条xml

    <dubbo:reference interface="com.sundablog.service.TestService" id="testService" version="1.0.0" />
    

    6、编写控制器类

    package com.sundablog.controller;
    
    
    
    import java.util.List;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    import com.sundablog.pojo.AdminUser;
    import com.sundablog.service.TestService;
    
    @Controller
    public class TestController {
    
    	@Autowired
    	public TestService testService;
    	
    	
    	@RequestMapping("/test")
    	@ResponseBody
    	public List<AdminUser> text(){
    		return testService.selectAdmin();
    	}
    }
    

    7.运行

    先把其他maven 工程使用install 打车jar包 使用命令 clean tomcat7:run 运行

    7.1运行结果

    [
        {
            "userId": 3, 
            "username": "admin", 
            "password": "123", 
            "salt": "123", 
            "realname": "12", 
            "avatar": "12", 
            "phone": "12", 
            "email": "12312", 
            "sex": 1, 
            "locked": 1, 
            "ctime": 1521023965000
        }
    ]
    
  • 相关阅读:
    LINQ/EF/Lambda 比较字符串日期时间大小
    WinForm RDLC SubReport Step by step
    centos7安装7-zip
    centos修改命令提示符颜色
    更换官方zabbix.repo为阿里云镜像
    利用shell脚本清理nginx日志
    docker
    centos 建立静态 IP 与 IP 地址丢失的解决办法
    构建lnmp高可用架构
    keepalived高可用
  • 原文地址:https://www.cnblogs.com/sundaboke/p/8616776.html
Copyright © 2011-2022 走看看