- @Controller:修饰class,用来创建处理http请求的对象
- @RestController:Spring4之后加入的注解,原来在@Controller中返回json需要@ResponseBody来配合,如果直接用@RestController替代@Controller就不需要再配置@ResponseBody,默认返回json格式。
- @RequestMapping:配置url映射
springboot:整合Mybatis通用Mapper插件
项目地址:https://github.com/snjl/springboot.auto-mybatis.git
项目配置
- Spring Boot: 1.5.9.RELEASE
- Maven: 3.5
- Java: 1.8
- Thymeleaf: 3.0.7.RELEASE
- Vue.js: v2.5.11
springboot:全局异常处理整理
项目地址:https://github.com/snjl/springboot.auto-mybatis.git
介绍Spring Boot默认的异常处理机制
默认情况下,Spring Boot为两种情况提供了不同的响应方式。
一种是浏览器客户端请求一个不存在的页面或服务端处理发生异常时,一般情况下浏览器默认发送的请求头中Accept: text/html,所以Spring Boot默认会响应一个html文档内容,称作“Whitelabel Error Page”。
docker:简介
维基百科:
Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and a union-capable filesystem such as aufs and others to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines.
Docker是一个开放源代码软件项目,让应用程序布署在软件容器下的工作可以自动化进行,借此在Linux操作系统上,提供一个额外的软件抽象层,以及操作系统层虚拟化的自动管理机制。Docker利用Linux核心中的资源分离机制,例如cgroups,以及Linux核心命名空间(name space),来建立独立的软件容器(containers)。这可以在单一Linux实体下运作,避免启动一个虚拟机器造成的额外负担。——摘自维基百科
matplotlib画3D图
1 | from matplotlib import pyplot as plt |
react:设置global变量
创建一个config.js,在其他react的js文件中引入:1
2
3
4
5
6
7
8
9global.serverConfig = {
domainName:'http://localhost',
port:'2222',
project:'project',
};
global.server = {
host:global.serverConfig.domainName + ':' + global.serverConfig.port + '/' + global.serverConfig.project + '/',
};
即1
global.server.host = 'httpL//localhost:2222/project/'
其他react的js文件中引入并可以直接调用:1
2
3import '/config'
alert(global.server.host)
react:搜索中设置回车搜索和点击搜索
1 | class Com_search extends Component { |
搜索框使用onKeyDown方法,在keyDownSearch中判断按键是否为回车,回车即调用;
点击div的搜索,即调用onClick方法,直接进行搜索。
react:form的textarea
使用react框架的form表单,input标签填入this.state的值的时候,要用defaultValue,使用value属性会报错;
但是使用textarea,要使用value属性,使用defaultValue属性不能显示this.state的值。
springboot:测试,打包,部署
开发阶段
单元测试
在pom包中添加spring-boot-starter-test包引用
1
2
3
4
5<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>开发测试类
以最简单的helloworld为例,在测试类的类头部需要添加:@RunWith(SpringRunner.class)和@SpringBootTest注解,在测试方法的顶端添加@Test即可,最后在方法上点击右键run就可以运行。