上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页

11-springboot静态资源访问

摘要: 静态资源:js, css, html, 图片,音视频等; 静态资源路径:是指系统可以直接访问的路径,且路径下的所有文件均可被用户直接访问; Spring Boot默认静态资源目录位置位于classpath下,目录名需符合如下规则: /static /public /META-INF/resource 阅读全文
posted @ 2023-03-23 10:46 companion 阅读(22) 评论(0) 推荐(0) 编辑

10-springboot统一处理404错误

摘要: 404不是异常,是找不到的情况 当输入地址有误,会进入springboot默认的白板404页面,对用户不太友好,我们可以统一定义一个全局的404错误处理; @Beanpublic WebServerFactoryCustomizer<ConfigurableWebServerFactory> web 阅读全文
posted @ 2023-03-23 10:41 companion 阅读(284) 评论(0) 推荐(0) 编辑

9-springboot统一异常处理

摘要: 500错误页面之前可以xml中配置errorpage的配置,或者tomcat的web.xml中处理,现在可以进行统一处理。 新建处理类统一处理 @ControllerAdvice -> 如果改成RestControllerAdvice 那么里面的方法就不用加@ResponseBody的内容,但是只能 阅读全文
posted @ 2023-03-22 17:41 companion 阅读(21) 评论(0) 推荐(0) 编辑

8-springboot使用拦截器

摘要: 参考文章: https://blog.csdn.net/leeta521/article/details/119532691 SpringBoot通过实现HandlerInterceptor接口实现拦截器,通过实现WebMvcConfigurer接口实现一个配置类,在配置类中注入拦截器,最后再通过@ 阅读全文
posted @ 2023-03-22 15:41 companion 阅读(20) 评论(0) 推荐(0) 编辑

Spring全家桶中各个注解的用法

摘要: 1.@ResponseBody @responseBody注解的作用是将controller的方法返回的对象通过适当的转换器转换为指定的格式之后,写入到response对象的body区,通常用来返回JSON数据或者是XML数据。注意:在使用此注解之后不会再走视图处理器,而是直接将数据写入到输入流中, 阅读全文
posted @ 2023-03-22 15:26 companion 阅读(21) 评论(0) 推荐(0) 编辑

7-springboot-多数据源事务管理-jta+atomikos的分布式事务

摘要: jta+atomikos的分布式事务 <!--jta+atomikos分布式事务--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jta-atomikos</arti 阅读全文
posted @ 2023-03-22 14:31 companion 阅读(200) 评论(0) 推荐(0) 编辑

6-springboot配置多数据源

摘要: 1.application.properties中配置多数据源 #refund数据源#此种标黄的没办法自己进行解析,代码读取spring.datasource.refunddb.url=jdbc:mysql://refund地址spring.datasource.refunddb.username= 阅读全文
posted @ 2023-03-22 13:56 companion 阅读(145) 评论(0) 推荐(0) 编辑

4-springboot多数据源配置报错Cause: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName

摘要: springboot2.0版本以上的多数据源配置改成: spring.datasource.refunddb.url=jdbc:mysql://refund地址spring.datasource.refunddb.username=uatspring.datasource.refunddb.pass 阅读全文
posted @ 2023-03-21 16:54 companion 阅读(67) 评论(0) 推荐(0) 编辑

3-springboot编译报错Relying upon circular references is discouraged and they are prohibited by default

摘要: 如果是.properties文件,在文件中添加 spring.main.allow-circular-references=true 如果是.yml文件,则在文件中添加 spring: main: allow-circular-references:true文章参考:https://blog.csd 阅读全文
posted @ 2023-03-21 14:31 companion 阅读(1258) 评论(0) 推荐(0) 编辑

5-springboot集成热部署的方式

摘要: 热部署是指当我们修改代码后,服务能自动重启加载新修改的内容,这样大大提高了我们开发的效率; Spring boot热部署通过添加一个插件实现; 插件为:spring-boot-devtools,在Maven中配置如下: <!-- springboot 开发自动热部署 --> <dependency> 阅读全文
posted @ 2023-03-21 10:12 companion 阅读(16) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页