Spring Boot

Spring Boot 面试题

*springboot核心注解
@SpringBootApplication:主要组合了@SpringBootConfiguration,@EnableAutoConfiguration,@ComponentScan;
@SpringBootConfiguration:这是Spring Boot 项目的相关配置注解,其实它也是一个组合注解。
@EnableAutoConfiguration:启用自动配置,该注解会使Spring Boot根据项目中依赖的jar包自动配置项目的配置项:如:我们添加了spring-boot-starter-web的依赖,项目中也就会引入SpringMVC的依赖,并且Spring Boot会自动配置tomcat 和SpringMVC。
@ComponentScan:默认扫描@SpringBootApplication 所在类的同级目录以及它的子目录。
@ImportResource:在实际项目中,如果必须使用xml配置,可以通过@ImportResource来加载xml配置。
@ConditionalOnBean:当容器里有指定的Bean的条件下。

@ConditonalOnWebApplication:当前项目是Web项目的条件下。
这些注解都是组合了@Conditional元注解,只是使用了不同的条件。
@PropertySource:用来加载properies文件。
@Value:加载properties文件中的value值

@ResponseBody可以直接返回Json结果,
@ResponseEntity不仅可以返回json结果,还可以定义返回的HttpHeaders和HttpStatus

*Spring中的InitializingBean接口的使用

*spring注解为bean指定InitMethod和DestroyMethod

*初步认识Thymeleaf:简单表达式和标签(一)
初步认识Thymeleaf:简单表达式和标签(二)

*thymeleaf th:replace th:include th:insert 的区别
th:insert :保留自己的主标签,保留th:fragment的主标签。
th:replace :不要自己的主标签,保留th:fragment的主标签。

*thymeleaf的$和*的区别

*thymeleaf中$和#的区别

*Springboot+thymeleaf

*Springboot获取参数总结

*在Spring中常被忽视的注解 @Primary

*springboot–常用注解–@configration、@Bean

*SpringBoot学习:获取yml和properties配置文件的内容

*@RestController注解相当于@ResponseBody + @Controller合在一起的作用,常常用于返回JSON数据;

1.在pom中导入依赖

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.tianAn.springBootTest</groupId>
	<artifactId>springBoot-Test</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>springBoot-Test</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version><!--$NO-MVN-MAN-VER$-->
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
	</dependencies>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.0.RELEASE</version>
	</parent>
</project>

2.class文件中启动

package com.tianAn.springBootTest.springBoot_Test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class App {
	public static void main(String[] args) {
		SpringApplication.run(App.class, args);
	}

}

*SpringBoot+MyBatis简单数据访问应用http://www.cnblogs.com/lfjjava/p/6093114.html

使用springboot时mapper.xml无法加载的问题
https://blog.youkuaiyun.com/su20145104009/article/details/75144125/

*Springboot接受前端参数的计中方法
https://blog.youkuaiyun.com/a532672728/article/details/78057218
1.@RequestParam一般用于get方式,也可以用于post方式,但用于post方式需要按照表单提交方式提交,也就是ContentType:application/x-www-form-urlencoded
2.@RequestBody只能用于post方式,接收一个对象或者map,ContentType一般为json或者xml
3.HttpServletRequest最古老的获取方式,也是通过表单提交获取
4.@PathVariable获取路径参数
5.@ModelAttribute和@RequestBody类似,也是映射到model上,没尝试过是否支持map形式

*Thymeleaf引入外部css+js文件>>原文内容

*AOP记录请求日志
https://www.cnblogs.com/junjiang3/p/9033038.html

*AOP+反射记录日志
https://blog.youkuaiyun.com/bicheng4769/article/details/80007362

*spring aop 获取拦截类中的属性的值
https://blog.youkuaiyun.com/chaoyue1397/article/details/50686719

*Spring注解@Component,@Repository,@Service,@Controller,@Resource,@Qualifier区别
https://blog.youkuaiyun.com/qq_38663729/article/details/80681170

Spring中的注解@Service @Component @Controller @Repository的放置位置
https://www.cnblogs.com/lonecloud/p/5745885.html

*使用resttemplate post json
https://segmentfault.com/a/1190000007322338

*Java RestTemplate post请求传递参数遇到的坑
https://blog.youkuaiyun.com/ldy1016/article/details/80002126

*JavaScript(jQuery)获取thymeleaf的值
https://blog.youkuaiyun.com/qq_39446719/article/details/81259322

*Thymeleaf的普通表单提交与AJAX提交
https://blog.youkuaiyun.com/ZHANGLI_WORB/article/details/80888865

*利用maven的resources、filter和profile实现不同环境使用不同配置文件
http://zhaoshijie.iteye.com/blog/2094478
http://www.cnblogs.com/0201zcr/p/6262762.html

*Spring boot 集成mybatis通用mapper配置步骤及注意事项
https://blog.youkuaiyun.com/gdift/article/details/78987162

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值