接上一篇:企业实战03_SSM整合ActiveMQ支持多种类型消息https://blog.csdn.net/weixin_40816738/article/details/100572104
1、StreamMessage java原始值数据流
2、MapMessage 键值对
3、TextMessage 字符串
4、ObjectMessage 一个序列化的java对象
5、BytesMessage 一个字节的数据流
此文章为企业实战的展示操作,如果有地方不懂请留言,我看到后,会进行统一回复,让我们一起进步,为自己加油!!!
项目名 | 项目说明 |
---|---|
ssm-activemq | 父工程,统一版本控制 |
producer | 生产者 |
consumer | 消费者 |
base-pojo | 公共实体类 |
base-dao | 公共接口,数据库连接 |
文章目录
- 四、base-dao操作
- 4.1. 创建接口UserMapper
- 4.2. 在resources目录下面操作
- 4.2.1. 创建mybatis文件夹
- 4.2.2. 在mybatis文件夹下,新建db.properties文件
- 4.2.3. 在mybatis文件夹下,新建SqlMapConfig.xml文件
- 4.2.4. 在resources文件夹下,创建spring文件夹
- 4.2.5. 在spring文件夹下,创建applicationContext-dao.xml文件
- 4.2.6. 在spring文件夹下,创建applicationContext-service.xml文件
四、base-dao操作
4.1. 创建接口UserMapper
package com.gblfy.mq.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gblfy.mq.entity.User;/*** @author gblfy* @ClassNme UserMapper* @Description TODO* @Date 2019/9/4 23:54* @version1.0*/
public interface UserMapper extends BaseMapper<User> {
}
4.2. 在resources目录下面操作
4.2.1. 创建mybatis文件夹
4.2.2. 在mybatis文件夹下,新建db.properties文件
#数据库连接
#适用于mysql 6.x及以上
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/lcs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
jdbc.username=root
jdbc.password=root#适用于mysql 5.x
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://DB Host:DB Port/order?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
#jdbc.username=DB Username
#jdbc.password=DB Password
4.2.3. 在mybatis文件夹下,新建SqlMapConfig.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration></configuration>
4.2.4. 在resources文件夹下,创建spring文件夹
4.2.5. 在spring文件夹下,创建applicationContext-dao.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 数据库连接池 --><!-- 加载配置文件 --><context:property-placeholder location="classpath:mybatis/*.properties" /><!-- 数据库连接池 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close"><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><property name="driverClassName" value="${jdbc.driver}" /><property name="maxActive" value="10" /><property name="minIdle" value="5" /></bean><!-- 让spring管理sqlsessionfactory 使用mybatis和spring整合包中的 --><bean id="sqlSessionFactoryBean" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean"><!-- 数据库连接池 --><property name="dataSource" ref="dataSource"/><!-- 加载mybatis的全局配置文件 --><property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /></bean><!--配置mybatis 扫描mapper接口的路径--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.gblfy.mq.mapper"/></bean>
</beans>
4.2.6. 在spring文件夹下,创建applicationContext-service.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- spring自动去扫描base-pack下面或者子包下面的java文件--><!--管理Service实现类--><context:component-scan base-package="com.gblfy.mq"/>
</beans>
下一篇:企业实战05_SSM整合ActiveMQ支持多种类型消息https://blog.csdn.net/weixin_40816738/article/details/100572129
本专栏项目下载链接:
下载方式 | 链接详细 |
---|---|
GitLab项目 | https://gitlab.com/gb-heima/ssm-activemq |
Git | git clone git@gitlab.com:gb-heima/ssm-activemq.git |
zip包 | https://gitlab.com/gb-heima/ssm-activemq/-/archive/master/ssm-activemq-master.zip |
Fork地址 | https://gitlab.com/gb-heima/ssm-activemq/-/forks/new |