当前位置:   article > 正文

Springboot整合_classfinal springboot

classfinal springboot
  • 新建一个Spring Initializr项目

  • 创建项目的文件结构以及jdk的版本 

  • 选择项目所需要的依赖

 

  •  POM文件修改

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.6.4</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>aoyi</groupId>
  12. <artifactId>sn</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>sn</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>1.8</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-test</artifactId>
  27. <scope>test</scope>
  28. </dependency>
  29. <dependency>
  30. <groupId>org.springframework.boot</groupId>
  31. <artifactId>spring-boot-starter-web</artifactId>
  32. </dependency>
  33. <dependency>
  34. <groupId>mysql</groupId>
  35. <artifactId>mysql-connector-java</artifactId>
  36. <version>8.0.28</version>
  37. </dependency>
  38. <dependency>
  39. <groupId>org.projectlombok</groupId>
  40. <artifactId>lombok</artifactId>
  41. </dependency>
  42. <dependency>
  43. <groupId>org.mybatis</groupId>
  44. <artifactId>mybatis</artifactId>
  45. <version>3.5.0</version>
  46. </dependency>
  47. <!--缺少此jar包,导致@Mapper注解无效-->
  48. <dependency>
  49. <groupId>org.mybatis.spring.boot</groupId>
  50. <artifactId>mybatis-spring-boot-starter</artifactId>
  51. <version>2.0.1</version>
  52. <exclusions>
  53. <exclusion>
  54. <artifactId>mybatis</artifactId>
  55. <groupId>org.mybatis</groupId>
  56. </exclusion>
  57. </exclusions>
  58. </dependency>
  59. <!--分页插件-->
  60. <dependency>
  61. <groupId>com.github.pagehelper</groupId>
  62. <artifactId>pagehelper-spring-boot-starter</artifactId>
  63. <version>1.2.5</version>
  64. <exclusions>
  65. <exclusion>
  66. <artifactId>mybatis-spring-boot-starter</artifactId>
  67. <groupId>org.mybatis.spring.boot</groupId>
  68. </exclusion>
  69. </exclusions>
  70. </dependency>
  71. <!--swagger-->
  72. <dependency>
  73. <groupId>io.springfox</groupId>
  74. <artifactId>springfox-swagger2</artifactId>
  75. <version>2.7.0</version>
  76. </dependency>
  77. <!--swagger ui-->
  78. <dependency>
  79. <groupId>io.springfox</groupId>
  80. <artifactId>springfox-swagger-ui</artifactId>
  81. <version>2.7.0</version>
  82. </dependency>
  83. <dependency>
  84. <groupId>com.alibaba</groupId>
  85. <artifactId>fastjson</artifactId>
  86. <version>1.2.29</version>
  87. </dependency>
  88. <dependency>
  89. <groupId>org.apache.commons</groupId>
  90. <artifactId>commons-lang3</artifactId>
  91. <version>3.10</version>
  92. </dependency>
  93. <!--rabbitmq 依赖客户端--> <dependency>
  94. <groupId>com.rabbitmq</groupId>
  95. <artifactId>amqp-client</artifactId>
  96. <version>5.8.0</version>
  97. </dependency>
  98. <!--操作文件流的一个依赖--> <dependency>
  99. <groupId>commons-io</groupId>
  100. <artifactId>commons-io</artifactId>
  101. <version>2.6</version>
  102. </dependency>
  103. </dependencies>
  104. <build>
  105. <!--读取数据库配置-->
  106. <resources>
  107. <resource>
  108. <directory>src/main/resources</directory>
  109. <includes>
  110. <include>**/*.properties</include>
  111. <include>**/*.xml</include>
  112. <include>**/*.yml</include>
  113. </includes>
  114. <filtering>true</filtering>
  115. </resource>
  116. </resources>
  117. <plugins>
  118. <plugin>
  119. <groupId>org.springframework.boot</groupId>
  120. <artifactId>spring-boot-maven-plugin</artifactId>
  121. </plugin>
  122. <!-- 具体插件,逆向工程的操作是以构建过程中插件形式出现的 --> <plugin>
  123. <groupId>org.mybatis.generator</groupId>
  124. <artifactId>mybatis-generator-maven-plugin</artifactId>
  125. <version>1.3.0</version>
  126. <!-- 插件的依赖 -->
  127. <dependencies>
  128. <!-- 逆向工程的核心依赖 -->
  129. <dependency>
  130. <groupId>org.mybatis.generator</groupId>
  131. <artifactId>mybatis-generator-core</artifactId>
  132. <version>1.3.2</version> </dependency>
  133. <!-- 数据库连接池 -->
  134. <dependency>
  135. <groupId>com.mchange</groupId>
  136. <artifactId>c3p0</artifactId>
  137. <version>0.9.2</version>
  138. </dependency>
  139. <!-- MySQL驱动 -->
  140. <dependency>
  141. <groupId>mysql</groupId>
  142. <artifactId>mysql-connector-java</artifactId>
  143. <version>5.1.8</version> </dependency>
  144. </dependencies>
  145. </plugin>
  146. </plugins>
  147. </build>
  148. </project>
  • 修改配置文件

将resource文件夹下原有的application.properties文件删除,创建application.yml配置文件(备注:其实SpringBoot底层会把application.yml文件解析为application.properties),本文创建了两个yml文件(application.yml和application-dev.yml)

application.yml

  1. spring:
  2. profiles:
  3. active: dev

application-dev.yml

  1. server:
  2. port: 8080
  3. spring:
  4. datasource:
  5. username: root
  6. password: 1234
  7. url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
  8. driver-class-name: com.mysql.jdbc.Driver
  9. #解决循环依赖的问题
  10. main:
  11. allow-circular-references: true
  12. mybatis:
  13. mapper-locations: classpath:mapping/*.xml
  14. type-aliases-package: org.aoyi.sn.entity
  15. pagehelper:
  16. helperDialect: mysql
  17. reasonable: true
  18. page-size-zero: true
  19. supportMethodsArguments: true
  20. params: count=countSql
  21. #showSql
  22. logging:
  23. level:
  24. com.example.demo.mapper: debug

在项目中配置多套环境的配置方法。
 

笔记:在Spring Boot中多环境配置文件名需要满足application-{profile}.yml的格式,其中{profile}对应你的环境标识,比如:

application-dev.yml:开发环境
application-test.yml:测试环境
application-prod.yml:生产环境

至于哪个具体的配置文件会被加载,需要在application.yml文件中通过spring.profiles.active属性来设置,其值对应{profile}值。

  • 配置 mybatis-generator-core

  • resource文件下创建generatorConfig.xml文件
  • 修改自己要生成的位置
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE generatorConfiguration
  3. PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  4. "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
  5. <generatorConfiguration>
  6. <!-- targetRuntime: 执行生成的逆向工程的版本 MyBatis3Simple: 生成基本的CRUD(清新简洁版)
  7. MyBatis3: 生成带条件的CRUD(奢华尊享版) -->
  8. <context id="DB2Tables" targetRuntime="MyBatis3Simple">
  9. <!-- 数据库的连接信息 -->
  10. <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://rm-bp1vc9osk3mo2o4h3lo.mysql.rds.aliyuncs.com:端口/数据库名称" userId=" " password=" "></jdbcConnection>
  11. <!-- javaBean的生成策略-->
  12. <javaModelGenerator targetPackage="org.aoyi.sn.entity" targetProject=".\src\main\java">
  13. <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" />
  14. </javaModelGenerator>
  15. <!-- SQL映射文件的生成策略 xml生成 -->
  16. <sqlMapGenerator targetPackage="mapping" targetProject=".\src\main\resources">
  17. <property name="enableSubPackages" value="true" />
  18. </sqlMapGenerator>
  19. <!-- Mapper接口的生成策略 -->
  20. <javaClientGenerator type="XMLMAPPER" targetPackage="org.aoyi.sn.mapper" targetProject=".\src\main\java">
  21. <property name="enableSubPackages" value="true" />
  22. </javaClientGenerator>
  23. <!-- 逆向分析的表 -->
  24. <!-- tableName设置为*号,可以对应所有表,此时不写domainObjectName -->
  25. <!-- domainObjectName属性指定生成出来的实体类的类名 -->
  26. <table tableName="aoyi_sn_order" domainObjectName="AoyiSnOrder" />
  27. </context>
  28. </generatorConfiguration>
  • 右键Run maven build

  • 生成效果

  • 基本方法都已经生成好了

  • 启动类配置扫描mapper

  • resource文件下创建logback-spring.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration scan="true" scanPeriod="10 seconds">
  3. <contextName>logback</contextName>
  4. <property name="log.path" value="D:/project/helen/guli_log/edu" /> //输出路径
  5. <!--控制台日志格式:彩色日志-->
  6. <!-- magenta:洋红 -->
  7. <!-- boldMagenta:粗红-->
  8. <!-- cyan:青色 -->
  9. <!-- white:白色 -->
  10. <!-- magenta:洋红 -->
  11. <property name="CONSOLE_LOG_PATTERN"
  12. value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%blue(%thread) |%blue(%file:%line) |%green(%logger) |%cyan(%msg%n)"/>
  13. <!--文件日志格式-->
  14. <property name="FILE_LOG_PATTERN"
  15. value="%date{yyyy-MM-dd HH:mm:ss} |%-5level |%thread |%file:%line |%logger |%msg%n" />
  16. <!--编码-->
  17. <property name="ENCODING"
  18. value="UTF-8" />
  19. <!--输出到控制台-->
  20. <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  21. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  22. <!--日志级别-->
  23. <level>DEBUG</level>
  24. </filter>
  25. <encoder>
  26. <!--日志格式-->
  27. <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  28. <!--日志字符集-->
  29. <charset>${ENCODING}</charset>
  30. </encoder>
  31. </appender>
  32. <!--输出到文件-->
  33. <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  34. <!--日志过滤器:此日志文件只记录INFO级别的-->
  35. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  36. <level>INFO</level>
  37. <onMatch>ACCEPT</onMatch>
  38. <onMismatch>DENY</onMismatch>
  39. </filter>
  40. <!-- 正在记录的日志文件的路径及文件名 -->
  41. <file>${log.path}/log_info.log</file>
  42. <encoder>
  43. <pattern>${FILE_LOG_PATTERN}</pattern>
  44. <charset>${ENCODING}</charset>
  45. </encoder>
  46. <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
  47. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  48. <!-- 每天日志归档路径以及格式 -->
  49. <fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  50. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  51. <maxFileSize>100MB</maxFileSize>
  52. </timeBasedFileNamingAndTriggeringPolicy>
  53. <!--日志文件保留天数-->
  54. <maxHistory>15</maxHistory>
  55. </rollingPolicy>
  56. </appender>
  57. <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  58. <!-- 日志过滤器:此日志文件只记录WARN级别的 -->
  59. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  60. <level>WARN</level>
  61. <onMatch>ACCEPT</onMatch>
  62. <onMismatch>DENY</onMismatch>
  63. </filter>
  64. <!-- 正在记录的日志文件的路径及文件名 -->
  65. <file>${log.path}/log_warn.log</file>
  66. <encoder>
  67. <pattern>${FILE_LOG_PATTERN}</pattern>
  68. <charset>${ENCODING}</charset> <!-- 此处设置字符集 -->
  69. </encoder>
  70. <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
  71. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  72. <fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  73. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  74. <maxFileSize>100MB</maxFileSize>
  75. </timeBasedFileNamingAndTriggeringPolicy>
  76. <!--日志文件保留天数-->
  77. <maxHistory>15</maxHistory>
  78. </rollingPolicy>
  79. </appender>
  80. <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  81. <!-- 日志过滤器:此日志文件只记录ERROR级别的 -->
  82. <filter class="ch.qos.logback.classic.filter.LevelFilter">
  83. <level>ERROR</level>
  84. <onMatch>ACCEPT</onMatch>
  85. <onMismatch>DENY</onMismatch>
  86. </filter>
  87. <!-- 正在记录的日志文件的路径及文件名 -->
  88. <file>${log.path}/log_error.log</file>
  89. <encoder>
  90. <pattern>${FILE_LOG_PATTERN}</pattern>
  91. <charset>${ENCODING}</charset> <!-- 此处设置字符集 -->
  92. </encoder>
  93. <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
  94. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  95. <fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  96. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  97. <maxFileSize>100MB</maxFileSize>
  98. </timeBasedFileNamingAndTriggeringPolicy>
  99. <!--日志文件保留天数-->
  100. <maxHistory>15</maxHistory>
  101. </rollingPolicy>
  102. </appender>
  103. <!--开发环境-->
  104. <springProfile name="dev">
  105. <!--可以灵活设置此处,从而控制日志的输出-->
  106. <root level="DEBUG">
  107. <appender-ref ref="CONSOLE" />
  108. <appender-ref ref="INFO_FILE" />
  109. <appender-ref ref="WARN_FILE" />
  110. <appender-ref ref="ERROR_FILE" />
  111. </root>
  112. </springProfile>
  113. <!--生产环境-->
  114. <springProfile name="pro">
  115. <root level="ERROR">
  116. <appender-ref ref="ERROR_FILE" />
  117. </root>
  118. </springProfile>
  119. </configuration>

创建util包 封装返回值

  1. package aoyi.sn.util;
  2. /**
  3. *
  4. * @author LEOH
  5. *
  6. */
  7. public class BaseResult<T> {
  8. private String retMsg;
  9. private String retCode;
  10. private T data;
  11. public T getData() {
  12. return data;
  13. }
  14. public void setData(T data) {
  15. this.data = data;
  16. }
  17. public String getRetMsg() {
  18. return retMsg;
  19. }
  20. public void setRetMsg(String retMsg) {
  21. this.retMsg = retMsg;
  22. }
  23. public String getRetCode() {
  24. return retCode;
  25. }
  26. public void setRetCode(String retCode) {
  27. this.retCode = retCode;
  28. }
  29. public BaseResult<T> buildOk(T t, String retMsg) {
  30. BaseResult<T> tBaseResult = new BaseResult<>();
  31. tBaseResult.data = t;
  32. tBaseResult.retCode = Constants.SuccessCode;
  33. tBaseResult.retMsg = retMsg;
  34. return tBaseResult;
  35. }
  36. public BaseResult<T> buildFail(String retMsg){
  37. BaseResult<T> tBaseResult = new BaseResult<>();
  38. tBaseResult.retCode = Constants.FailCode;
  39. tBaseResult.retMsg = retMsg;
  40. return tBaseResult;
  41. }
  42. }
  1. package aoyi.sn.util;
  2. public class Constants {
  3. public static final String Query = "[查询]";
  4. public static final String Add = "[新增]";
  5. public static final String Update = "[更新]";
  6. public static final String Delete = "[删除]";
  7. public static final String Duplicate = "[重复]";
  8. public static String SplitChar = "_";
  9. /**
  10. * 24*3600*10 10 days
  11. */
  12. public static final long ExpireTime = 864000;
  13. public static final String FailCode = "FAIL";
  14. public static final String SuccessCode = "OKAY";
  15. public static final int PageSize = 10;
  16. }

select标签常用属性

parameterType   传入参数  支持map javaBean等值  resultMap 返回参数


Mapper增加

public List<AoyiSnCategory> selectAll(Map<String, Object> paras);

xml增加

  1. <sql id="Base_Column_List">
  2. id, create_by, create_time,
  3. update_by, update_time, sn_category_id,
  4. sn_category_name, sn_category_level, sn_category_parent_id
  5. </sql>
  1. <select id="selectAll" resultMap="BaseResultMap" >
  2. select <include refid="Base_Column_List" />
  3. from aoyi_sn_category
  4. </select>

创建service

  1. @Service
  2. public interface AoyiSnCategoryService {
  3. public BaseResult<PageInfo<AoyiSnCategory>> getSnCategorys(Map<String, Object> paras);
  4. }

创建serviceimpl

  1. import java.util.*;
  2. @Service
  3. @Transactional(rollbackFor = { RuntimeException.class, Exception.class })
  4. public class AoyiSnCategoryServiceImpl implements AoyiSnCategoryService {
  5. private static final Logger logger = LoggerFactory.getLogger(AoyiSnCategoryService.class);
  6. @Autowired
  7. private AoyiSnCategoryMapper aoyiSnCategoryMapper;
  8. @Override
  9. public BaseResult<PageInfo<AoyiSnCategory>> getSnCategorys(Map<String, Object> paras) {
  10. logger.info("查询类型列表");
  11. BaseResult<PageInfo<AoyiSnCategory>> baseRet = new BaseResult<PageInfo<AoyiSnCategory>>();
  12. baseRet.setRetCode(Constants.FailCode);
  13. baseRet.setRetMsg(Constants.Query);
  14. int pageNo = Integer.parseInt(String.valueOf(paras.get("pageNo")));
  15. int pageSize = Integer.parseInt(String.valueOf(paras.get("pageSize")));
  16. PageHelper.startPage(pageNo, pageSize);
  17. List<AoyiSnCategory> list = aoyiSnCategoryMapper.selectAll(paras);
  18. PageInfo<AoyiSnCategory> pageDataList = new PageInfo<AoyiSnCategory>(list);
  19. baseRet.setData(pageDataList);
  20. baseRet.setRetCode(Constants.SuccessCode);
  21. return baseRet;
  22. }
  23. }

controller

  1. @RestController
  2. @RequestMapping("/AoyiSnCategory")
  3. public class AoyiSnCategoryController {
  4. @Autowired
  5. private AoyiSnCategoryService aoyiSnCategoryService;
  6. //查询
  7. @RequestMapping(value = "getAoyiSnCategorys", method = RequestMethod.POST)
  8. @ResponseBody
  9. public BaseResult<PageInfo<AoyiSnCategory>> getDeviceTypeByParas(@RequestBody Map<String, Object> paras){
  10. return aoyiSnCategoryService.getSnCategorys(paras);
  11. }
  12. }

启动

测试查询    封装好了分页  查询2条 

配置了日志 打印sql 需下载mybatis Log 插件 

增加

 public Integer insertAoyiSnCategory(Map<String, Object>  paras);
  1. @Override
  2. public BaseResult<Integer> insertAoyiSnCategory(Map<String, Object> paras) {
  3. BaseResult<Integer> baseRet = new BaseResult<Integer>();
  4. baseRet.setRetCode(Constants.FailCode);
  5. baseRet.setRetMsg(Constants.Add);
  6. String createTime = DateUtil.formatYYYYMMDDHHMMSS(new Date());
  7. paras.put("createTime", createTime);
  8. paras.put("id", UUID.randomUUID().toString());
  9. Integer integerBaseResult = aoyiSnCategoryMapper.insertAoyiSnCategory(paras);
  10. baseRet.setData(integerBaseResult);
  11. baseRet.setRetCode(Constants.SuccessCode);
  12. return baseRet;
  13. }
  1. <insert id="insertAoyiSnCategory" parameterType="java.util.Map">
  2. insert into aoyi_sn_category (id, create_by, create_time,
  3. update_by, update_time, sn_category_id,
  4. sn_category_name, sn_category_level, sn_category_parent_id
  5. )
  6. values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  7. #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{snCategoryId,jdbcType=VARCHAR},
  8. #{snCategoryName,jdbcType=VARCHAR}, #{snCategoryLevel,jdbcType=VARCHAR}, #{snCategoryParentId,jdbcType=VARCHAR}
  9. )
  10. </insert>
  1. //增加
  2. @RequestMapping(value = "/insertAoyiSnCategorys", method = RequestMethod.POST)
  3. @ResponseBody
  4. public BaseResult<Integer> insertAoyiSnCategorys(@RequestBody Map<String, Object> paras){
  5. return aoyiSnCategoryService.insertAoyiSnCategory(paras);
  6. }

测试

修改

public int updateAoyiSnCategory(Map<String, Object> paras);

  1. <update id="updateAoyiSnCategory" parameterType="java.util.Map">
  2. update aoyi_sn_category
  3. <set>
  4. <if test="snCategoryName != null and snCategoryName != ''">sn_category_name = #{snCategoryName}</if>
  5. </set>
  6. WHERE
  7. id = #{id}
  8. </update>
  1. @Override
  2. public BaseResult<Integer> updateAoyiSnCategory(Map<String, Object> paras) {
  3. BaseResult<Integer> baseRet = new BaseResult<Integer>();
  4. baseRet.setRetCode(Constants.FailCode);
  5. baseRet.setRetMsg(Constants.Update);
  6. int ret = aoyiSnCategoryMapper.updateAoyiSnCategory(paras);
  7. baseRet.setData(ret);
  8. baseRet.setRetCode(Constants.SuccessCode);
  9. return baseRet;
  10. }
  1. @RequestMapping(value = "/updateAoyiSnCategory", method = RequestMethod.POST)
  2. @ResponseBody
  3. public BaseResult<Integer> updateAoyiSnCategory(@RequestBody Map<String, Object> paras){
  4. return aoyiSnCategoryService.updateAoyiSnCategory(paras);
  5. }

测试

删除

public BaseResult<Integer> deleteDeviceType(int id);

  1. @Override
  2. public BaseResult<Integer> delectAoyiSnCategory(String id) {
  3. BaseResult<Integer> baseRet = new BaseResult<Integer>();
  4. baseRet.setRetCode(Constants.FailCode);
  5. baseRet.setRetMsg(Constants.Delete);
  6. int ret = aoyiSnCategoryMapper.deleteByPrimaryKey(id);
  7. baseRet.setData(ret);
  8. baseRet.setRetCode(Constants.SuccessCode);
  9. return baseRet;
  10. }
  1. @RequestMapping(value = "/delectAoyiSnCategory", method = RequestMethod.POST)
  2. @ResponseBody
  3. public BaseResult<Integer> delectAoyiSnCategory(@RequestBody Map<String, Object> paras){
  4. return aoyiSnCategoryService.delectAoyiSnCategory((String) paras.get("id"));
  5. }

idea上传项目到gitee(码云)超详细 

(3条消息) idea上传项目到gitee(码云)超详细_『愚』的博客-CSDN博客_idea上传项目到gitee

剩下内容以后在加入

  1. package org.aoyi.sn.mqtt;
  2. import com.rabbitmq.client.Channel;
  3. import com.rabbitmq.client.Connection;
  4. import com.rabbitmq.client.ConnectionFactory;
  5. public class RabbitMqUtils {
  6. //得到一个连接的 channel
  7. public static Channel getChannel() throws Exception{
  8. //创建一个连接工厂
  9. ConnectionFactory factory = new ConnectionFactory();
  10. factory.setHost("192.168.1.125");
  11. factory.setUsername("admin");
  12. factory.setPassword("123");
  13. Connection connection = factory.newConnection();
  14. Channel channel = connection.createChannel();
  15. return channel;
  16. } }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/810156
推荐阅读
相关标签
  

闽ICP备14008679号