mkhl后台开发实例
来源:互联网 发布:od破解 e盾网络验证 编辑:程序博客网 时间:2024/05/21 17:15
1、首先创建实体类
这个实体类用于和数据库进行对接。
2、在sqlMapConfig.xml文件中定义该实体类的别名person。方便在mapper文件中使用
3、定义这个类的接口Dao类。这个是要和mapper文件对应的。其中所有用到的接口都要在这声明,具体的sql执行在mapper文件中。
其中mapper的命名空间必须为dao的路径,这样才能将两者关联。dao中的接口名和里面<select>方法的id名字是一致的。
<resultMap id="给ID名" type="实体类" >
<result column="数据库字段名" property="实体类属性" jdbcType="数据库字段类型" />
</resultMap>
4、然后创建service类,里面是和dao一样的接口声明。
5、然后具体的实现在impl里面实现。创建时要继承service类
序号1:因为是实现service,所以创建类时必须是继承
序号2:真正使用到的其实是dao里面的接口,dao里面的接口是操作数据库的,然后通过dao来操作数据库的结果之后,在这里进行运用。
注意:在dao中接口的返回值为person,也就是model里面的,但是因为在前台得要的字段不同我们可以自己定义组成一个新的实体类,即PersonDto类
因为dao里面返回的是person实体类,我们就需要在这里把前台需要用到的字段赋值到persondto中。这样的返回值就是我们需要的dto。
6、然后就是对spring文件的bean装配
其中1就是将dao进行bean装配,3的名字必须要和装配的id一致。2中的4要和2中的定义的PersonDao的UI想名一致。
7、client层的内容基本就是前台所需要的字段组成的实体类persondto。然后还有需要用到的接口。
8、client中的接口的具体实现是在impl层的。
因为是对client层的实现,所以在创建时要继承client里面的接口类。
序号1的定义对象名字必须和biz层里面spring文件中装配的名称一样。也就是第6题目中的2号。
9、然后就是在impl层中spring装配。
同样将impl文件进行装配。3的名字必须和impl里面的实现接口类中定义的一样。而4ref的是需要和biz里面装配的名字一样。其中编号2用于dubbo发布服务。
10、后台测试:
package com.ouc.mkhl.platform.common;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.ouc.mkhl.platform.person.dto.PersonDto;import com.ouc.mkhl.platform.person.service.PersonServiceClient;public class PersonTest {private static final Logger LOG = LoggerFactory.getLogger(TestChenzf.class);private static PersonServiceClient personServiceClient;public static void main(String[] args) {ClassPathXmlApplicationContext cxt = new ClassPathXmlApplicationContext(new String[] {"classpath*:/console/audit/console-audit.xml", "classpath*:/console/dubbo/spring-external.xml","classpath*:/console/message/console-message-provider.xml", "classpath*:/spring/cache/spring-*.xml","classpath*:/spring/jmx/spring-jmx-mbean.xml", "classpath*:/spring/security/spring-*.xml","classpath*:/spring/person/spring-person.xml","classpath*:/spring/spring-common.xml","classpath*:/spring/spring-config-toolkit.xml", "classpath*:/spring/spring-datasource.xml","classpath*:/spring/spring-external.xml", "classpath*:/spring/spring-log.xml","classpath*:/spring/spring-monitor.xml", "classpath*:/spring/spring-transaction.xml", "classpath*:/spring_service/person/spring-Person-provider.xml","classpath*:/spring_service/spring-dubbo.xml", "classpath*:/spring-auth/spring-config.xml"});cxt.start();LOG.info("启动成功");personServiceClient=(PersonServiceClient)cxt.getBean("personServiceClient");//这里要和spring里面的一致,第6标题图片中的2PersonDto personDto=personServiceClient.selectByName("00575050");System.err.println(personDto.getUserName()+personDto.getTrueName()+personDto.getProduct());}}
- mkhl后台开发实例
- MAGENTO 后台模块开发实例
- 亿美短信开发实例后台代码
- DISCUZ 管理后台页面开发实例
- DISCUZ 管理后台页面开发实例
- 简单的dedecms在线报名插件开发 实例 有后台
- 后台开发
- 后台开发
- 后台开发
- Android 后台线程实例
- Jquery EasyUI后台实例
- Jquery EasyUI后台实例
- linux后台进程实例
- laravel rbac 后台实例
- 无刷新下拉实例后台
- ORACLE实例的后台进程
- ORACLE实例的后台进程
- ExtJs 与后台交互实例
- 关于类的继承Constructor call must be the first statement in a constructor问题
- R语言使用分词包错
- 线程同步与进程间通信的方式和机制
- Codeforces 55D
- hdu 1241 Oil Deposits DFS
- mkhl后台开发实例
- php面向对象_get(),_set()的用法
- java常用的数字证书
- sql 系统时间问题
- Android学习笔记——文件存储
- 刷题总结#3
- 集合框架
- 20170403_Linux视频学习1——Linux系统的基本命令
- React学习之相关代码库(三十六)