2019/04/08_SpringBoot_@RequestBody(required=false)_启动文件_Springboot 装载mybatis正在学习

本文介绍了在SpringBoot中使用@RequestBody注解时如何设置为非必需参数,以及SpringBoot启动时的数据源加载问题。同时,讨论了SpringBoot配置Mybatis的相关步骤,帮助读者理解SpringBoot应用的启动流程和Mybatis的集成。
摘要由CSDN通过智能技术生成

指定

appoint; assign; allocate; appointment; destine; designation; assigning:

(通过法律手续)指定把财产授与某人

settle one's property on sb.;

指定某人任某职

designate sb. to an office;

指定某人做某事

assign sb. to do sth.;

指定一个日期

appoint a date

执行

执行命令

execute an order;

执行任务

carry out a task

int 与 Integer

非new生成的Integer变量指向的是java常量池中的对象,而new Integer()生成的变量指向堆中新建的对象,两者在内存中的地址不同。所以 输出为false。

@RequestBody(required=false) 表示map对象可以不传入

public ResponseBodyVO<Integer> approveDisagreeDo(@RequestBody(required=false) Map<String, Object> map) throws BusinessException {
   	/*
   	 * 1.审批的操作:调用审批接口的操作
   	 * 2.工作流的操作:把运行表中的审批人ID置为空
   	 * 
   	 * approverAction:1:驳回 2:驳回并修改
   	 */
   	Integer approverAction = (Integer)map.get("approverAction");
   	String approvalStatus = null;
   	switch (approverAction) {
   	case 1:
   		approvalStatus="驳回";
   		break;
   	case 2:
   		approvalStatus="驳回并修改";
   		break;
   	}
   	approveBusiService.approveDo(map, approverAction);
   	logger.debug("组装更新运行表的map");
   	Map<String, Object> uMap = new HashMap<String,Object>();
   	uMap.put("applyId", map.get("applyId"));
   	uMap.put("curUserID", "");
   	uMap.put("approvalStatus",approvalStatus);
   	uMap.put("invariantField", "applyId");
   	rows=workflowApplyRunningService.updateMap(uMap);
   	ResponseBodyVO<Integer> responseBodyVO=new ResponseBodyVO<>();
   	responseBodyVO.setSuccessResult(rows);
   	return  responseBodyVO;
   }

Spring boot启动默认是要加载数据源,因此在 model 层出现问题的话,程序启动异常

Spring Boot 配置 mybatis

<dependency>
   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.0</version>
</dependency>

Spring Boot
启动文件
Spring 注解

package com.boxin.productions.stp.ttc;

import com.boxin.productions.sss.common.component.BaseComponent;
import com.boxin.productions.sss.common.component.interceptor.RequestInterceptor;
import com.boxin.productions.sss.common.jpa.service.SysUserService;

//import com.boxin.productions.sss.common.jpa.service.TicketsPropCategoryService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;


@Configuration
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
@EnableScheduling
//@EnableFeignClients
//@EnableDiscoveryClient
@ComponentScan(basePackageClasses = { boxinApplication.class, BaseComponent.class, SysUserService.class, RequestInterceptor.class})
public class boxinApplication extends SpringBootServletInitializer {
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(boxinApplication.class);
	}

	public static void main(String[] args) throws Exception {
		SpringApplication app = new SpringApplication(boxinApplication.class);
		app.run(args);
	}

}

Springboot 装载mybatis
MyBatis注解应用之动态SQL语句
	@DeleteProvider(type = DynamicSqlProvider.class, method = "deleteListByIds")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值