
SpringBoot
欧皇小德子
这个作者很懒,什么都没留下…
展开
-
SpringBoot -> spring-boot-maven-plugin爆红解决方法,当网上的其他方法解决不了时
只有一个问题,你是第一次使用这个 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plu原创 2020-10-20 21:32:40 · 941 阅读 · 1 评论 -
SpringBoot -> 官方pom.xml模板
<?xml version="1.0" encoding="UTF-8"?><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 https://maven.apache.org/xsd/maven-4.0.0.xsd">原创 2020-10-20 21:33:52 · 649 阅读 · 1 评论 -
SpringBoot -> 第一个Hello
mainpackage month10;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;/** * 功能描述:SpringBootApplication:指示一个配置类, * 该类声明一个或多个@Bean方法并触发自动配置和组件扫描。这是一个方便的注释 * @ClassName Day20 * @Aut原创 2020-10-21 10:30:05 · 146 阅读 · 0 评论 -
SpringBoot -> 第一个注入Bean和Yaml配置
1.YML配置program: age: 12 list: - 12 - 13 - 14 map: k1: a k2: b string: abc animal: name: dog anInt: 112.program类–做输出类package com.rod.springboot.yaml;import org.springframework.boot.context.properties.Configuration原创 2020-10-22 21:12:03 · 467 阅读 · 0 评论 -
SpringBoot -> application.yaml
#active:起作用;profiles:配置文件;port:端口#这里起作用的是叫prod的那一块,相应的端口号也叫8081#启动springboot的时候起作用的就不是前面这一块,是---下面的叫做prod的那一块spring: profiles: active: prodserver: port: 8080program: age: 2222222 list: - 12 - 13 - 14 map: k1: a k2: b原创 2020-10-23 20:12:34 · 328 阅读 · 0 评论 -
SpringBoot -> 当文件已经打成jar包后,cmd怎么运行并且修改端口号后正常运行(port)--附加:更加丝滑的方式
1.打包2.命令行启动jar端口8081正常启动3.在不改变jar包的情况下,修改端口号为8080--server.port=8080原创 2020-10-23 20:46:58 · 1506 阅读 · 0 评论 -
SpringBoot -> SLF4j日志官方示例--附加:打印到文件
import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class HelloWorld { public static void main(String[] args) { Logger logger = LoggerFactory.getLogger(HelloWorld.class); logger.info("Hello World"); }}maven的jar包–默认下载2.0.0及其以下所有版原创 2020-10-24 09:13:47 · 2394 阅读 · 0 评论 -
SpringBoot -> 资源默认访问位置
1.添加jquery.js的jar <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>3.5.1</version> </dependency>https://www.webjars.or原创 2020-10-24 16:41:04 · 522 阅读 · 0 评论 -
SpringBoot -> Thymaleaf自动渲染html(手动改变配置覆盖原来的配置,图片文字)
1.配置Thymaleaf <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>2.添加html到templetes文件夹,方法指定 @Reques原创 2020-10-24 18:19:43 · 485 阅读 · 0 评论 -
SpringBoot -> Thymeleaf获取map中的value显示到html中
1.html<!DOCTYPE html><!-- xmlns:th="http://www.thymeleaf.org" 命名空间:th:--><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>Title</title></head><原创 2020-10-25 16:30:11 · 1328 阅读 · 0 评论 -
SpringBoot -> Thymeleaf使用th:each遍历属性加入html
html<!DOCTYPE html><!-- xmlns:th="http://www.thymeleaf.org" 命名空间:th:--><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>Title</title></head><b原创 2020-10-25 19:10:46 · 1238 阅读 · 0 评论 -
SpringBoot -> ViewResolver(定制视图解析器)
1.视图解析类package com.rod.springweb;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Bean;import org.springframework.web.servlet.View;imp原创 2020-10-25 22:18:37 · 1230 阅读 · 0 评论 -
SpringBoot -> 使用WebMvcConfigurer扩展,视图映射(view)
1.配置SpringMvc扩展类package com.springweb.web;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfig原创 2020-10-26 15:18:44 · 665 阅读 · 0 评论 -
SpringBoot -> 国际化html(中英文转换)
1.proeprties文件2.html<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initia原创 2020-10-26 19:55:10 · 503 阅读 · 0 评论 -
SpringBoot -> banner(彩蛋),初始化的spring样式变为七龙珠
https://www.bootschool.net/ascii-art/cartoons?pageNO=2上网址,复制想要的样式原创 2020-11-22 21:04:59 · 300 阅读 · 1 评论 -
SpringBoot -> 自动装配初探,debug=ture判断配置类是否生效
文章目录第一个注解:@SpringBootApplication点进去有一堆注解:1.这4个是元注解:2.@SpringBootConfiguration @EnableAutoConfiguration @ComponentScan3.@AutoConfigurationPackage @Import:4.我们先进input的类里面看看5.getCandidateConfigurations:翻译:获取候选配置6.我们把方法拿下来这照着看7.开始参数:第一个getSpringFactoriesLoader原创 2020-11-23 13:58:37 · 2978 阅读 · 1 评论 -
SpringBoot -> 自动装配原理
1.先看看有多少自动配置类...# Spring Test ContextCustomizerFactoriesorg.springframework.test.context.ContextCustomizerFactory=\org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory,\org.springframework.boot.test.autoconfigu原创 2020-11-23 18:05:38 · 196 阅读 · 0 评论 -
SpringBoot -> thymeleaf导包
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.thymel...原创 2020-11-23 19:33:57 · 694 阅读 · 0 评论 -
SpringBoot -> 第一个thymeleaf
导包: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.thymeleaf原创 2020-11-23 19:48:26 · 138 阅读 · 0 评论 -
SpringBoot -> thymeleaf:遍历th:each
controller @RequestMapping("/hello") public String hello(Map<String, Object> map) { map.put("hello","<h1>hello<h2>"); map.put("user", Arrays.asList("111","222","333")); return "hello"; }htmlth:text="${hello}":获取变量hell原创 2020-11-23 20:19:44 · 558 阅读 · 0 评论 -
SpringBoot -> MVC自动配置,自定义视图解析器,转换器和格式化器,分析一点点源码
文章目录官网阅读ContentNegotiatingViewResolver 内容协商视图解析器官网阅读在进行项目编写前,我们还需要知道一个东西,就是SpringBoot对我们的SpringMVC还做了哪些配置,包括如何扩展,如何定制。只有把这些都搞清楚了,我们在之后使用才会更加得心应手。途径一:源码分析!途径二:官方文档!地址 :https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#boot-fe原创 2020-11-24 13:04:45 · 1426 阅读 · 0 评论 -
SpringBoot -> 首页实现(thymeleaf-index.html)
文章目录上结果1.蓝奏云资源2.扩展mvc:添加视图控制器3.index页面4.yaml配置:thymeleaf关闭缓存上结果1.蓝奏云资源https://rod.lanzous.com/b0dkgezdc2.扩展mvc:添加视图控制器@Configurationpublic class MyMvcConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRe原创 2020-11-24 14:45:31 · 1756 阅读 · 2 评论 -
SpringBoot -> 国际化(i18n)
文章目录上结果1.准备工作配置文件编写配置文件生效探究配置页面国际化值配置国际化解析总结:我可能骗了你们,这个看了我都总结不出什么东西上结果1.准备工作先在IDEA中统一设置properties的编码问题!编写国际化配置文件,抽取页面需要显示的国际化页面消息。我们可以去登录页面查看一下,哪些内容我们需要编写国际化的配置!配置文件编写1、我们在resources资源文件下新建一个i18n目录,存放国际化配置文件**为什么是i18n的目录:**英语单词中i后面有18个字母最后一个是n,所以是i原创 2020-11-24 18:58:55 · 13455 阅读 · 2 评论 -
SpringBoot -> 过滤器(filter)
过滤器:实现接口filter,重写方法@Component@WebFilter(urlPatterns = "/gethello") //需要过滤的url 是一个数组类型的,可以存多个public class MyFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doF原创 2020-11-26 19:36:20 · 455 阅读 · 0 评论 -
SpringBoot -> 使用WebMvcConfigurer扩展,拦截器(interceptor),监听器就实现各种listener接口
拦截器:实现接口handlerinterceptor@Componentpublic class MyInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {原创 2020-11-26 19:54:20 · 811 阅读 · 0 评论 -
SpringBoot -> 发送邮件
文章目录导包普通:创建一封简单的电子邮件springboot方式转载:利用java实现发送邮件转载:Spring Boot实现邮件发送导包如果是mvn项目的话,我们只需要添加依赖即可<dependency><groupId>javax.mail</groupId><artifactId>mail</artifactId><version>1.5.0-b01</version></dependency&原创 2020-11-28 12:01:38 · 434 阅读 · 0 评论 -
SpringBoot 配置数据库durid
文章目录导包配置yaml:配置数据库用户名密码配置类导包<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.21</version> </dependency> <dependency> <groupId>org.apa原创 2020-12-04 21:01:03 · 382 阅读 · 0 评论 -
SpringBoot -> 整合Mybatis
文章目录结构图导入mybatis-jar包配置druid数据源,过滤器pojo,mapper,mapper.xmlservice,controllerapplication.yamlspring启动类结构图导入mybatis-jar包<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</art原创 2020-12-06 09:25:12 · 88 阅读 · 0 评论 -
SpringBoot -> 集成SpringSecurity(安全)
文章目录蓝奏云资源controller跳转!测试实验环境是否OK!认识SpringSecurity认证和授权权限控制和注销记住我定制登录页完整配置代码蓝奏云资源https://rod.lanzous.com/b0dkhh5hacontroller跳转!@Controllerpublic class RouterController { @RequestMapping({"/","/index"}) public String index(){ return "index原创 2020-12-06 21:37:18 · 364 阅读 · 0 评论