
Springboot
wzng
再懒也不能停止运动
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
XXL-JOB学习笔记(二)
xxl支持多种路由策略。路由策略针对同一个job在不同group运行的策略,当同时启动多个同名的执行器例子时,这个执行器就有多个,如下:这样这个xxl-job-executor-sample下就有两个进程了,配置这个group下的的job的路由策略:具体策略详见com.xxl.job.admin.core.route.ExecutorRouteStrategyEnumFIRST(I18nUtil.getString("jobconf_route_first"), new Executo原创 2020-11-24 08:46:48 · 949 阅读 · 1 评论 -
XXL-JOB学习笔记(一)
源码去github下载下,先去执行sql新建几个表:打开主要分为3个部分:1,管理台2,核心3,执行例子运行xxl-job-admin,成功后打开管理台运行执行例子,我这边用的springboot的demo配置application.properties后启动# web portserver.port=8089# no web#spring.main.web-environment=false# log configlogging.c..原创 2020-11-19 20:45:04 · 709 阅读 · 0 评论 -
springboot项目里使用scala进行开发配置
<!--添加依赖--><dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId></dependency><!--添加plugin--><plugin> <groupId>net.alchim31.maven</groupId&g..原创 2020-05-27 17:50:42 · 989 阅读 · 0 评论 -
IDEA创建springboot项目,如何打war包,并在war包的pom.xml的配置下在idea里运行程序进行测试
使用idea创建sprinboot项目默认是打jar包的配置,内嵌tomcat可直接运行程序如果需要打war包,需要对pom.xmle文件进行配置1.排除内嵌的tomcat<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring...原创 2019-11-25 17:15:04 · 918 阅读 · 0 评论 -
springboot如何快速找到spring.factories文件
通过SpringApplication的类加载器获取System.out.println(SpringApplication.class.getClassLoader().getResource("META-INF/spring.factories"));输出:jar:file:/D:/maven/org/springframework/boot/spring-boot/2.2.0....原创 2019-11-06 11:41:12 · 5003 阅读 · 0 评论 -
springboot+thymeleaf使用highcharts实现折线图
首先使用下面的插件,可去https://download.youkuaiyun.com/download/qq_38522268/10689045下载<script th:src="@{/js/jquery-1.8.0.min.js}" type="text/javascript"></script><script type="text/javascript" th:s...原创 2018-09-26 17:20:14 · 3039 阅读 · 0 评论 -
springboot在implements HandlerInterceptor时controller类return 中文字符串时出现中文乱码
解决办法:我在拦截器里添加response.setHeader("Content-type", "text/html;charset=UTF-8");这句,但是返回的中文还是乱码,我把拦截器去掉后,返回正常,但是我需要这个拦截器实现request的跨域请求后来我直接在GetMapping(value = "/test2",produces = {"text/html;cha...原创 2018-09-21 16:33:50 · 1550 阅读 · 0 评论 -
IDEA的断点只有在main函数和测试类里能运行
打断点不是一个随便的程序就能运行的,一般需要专门的测试类里打断点,或者是main函数里原创 2018-09-19 08:16:50 · 1641 阅读 · 0 评论 -
springboot+thymeleaf在ajax方法的前后加loading效果
首先加入下面的插件,可到https://download.youkuaiyun.com/download/qq_38522268/10689121和https://download.youkuaiyun.com/download/qq_38522268/10689045下载<script th:src="@{/js/jquery-1.8.0.min.js}" type="text/javascript">...原创 2018-09-26 17:33:33 · 2074 阅读 · 1 评论 -
springboot+thymeleaf后台创建session,前端接收session
首先,在后台程序中创建sessionHttpSession session = request.getSession(true);session.setAttribute("openid",openid);然后在前端接收id为openid,的session<input type="hidden" name="openid" id="openid" th:value="$...原创 2018-09-27 08:46:00 · 6775 阅读 · 1 评论 -
springboot+thymeleaf接收前台传来的request,在js里获取到后台向前台传递的request
创建controller方法@GetMapping("/test")public String test(HttpServletRequest request){String openid = request.getParameter("openid");//接收传来的openidrequest.setAttribute("openid", openid);//将openid ...原创 2018-09-27 08:54:48 · 9229 阅读 · 8 评论 -
springboot+freemarker实现页面定时跳转
</h4> <strong>${msg}</strong><a href="${url}" class="alert-link">3s后自动跳转</a><script> setTimeout('location.href="${url}"', 3000);</script>...原创 2018-09-27 08:59:33 · 2112 阅读 · 0 评论 -
springboot+thymeleaf实现页面定时跳转
<strong></strong><a class="alert-link">3s后将自动跳转</a><script th:inline="javascript"> var openid=[[${openid}]]; var url="/sell/qrcode"; setTimeout('locati...原创 2018-09-27 09:02:02 · 2397 阅读 · 0 评论 -
Springboot2.0.4.RELEASE使用JPA自动建表报错Error executing DDL via JDBC Statement
在application.yml这样设置spring: jpa: show-sql: true hibernate: ddl-auto: update database-platform: org.hibernate.dialect.MySQL5InnoDBDialect报错是因为我没有加上 database-platform: org.hib...原创 2018-09-29 18:46:00 · 3934 阅读 · 0 评论 -
springboot集成elasticsearch
首先加入依赖<!--全文搜索--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId&...原创 2018-10-08 14:55:30 · 366 阅读 · 0 评论 -
IDEA下如何使用@Slf4j注解来输出日志
1,打开IDEA FILE->settings 在左上方的搜索框里输入lombok 选择Lombok Plugin点击右边的install (我这边已经安装好,显示的是update),点击ok2,注意安装完之后,重启idea,就可以使用@Slf4j注解了,这个注解用在类名上方@Slf4j@Controller@RequestMapping("/gprs...原创 2018-09-07 16:01:45 · 3036 阅读 · 0 评论 -
SpringBoot使用thymeleaf引擎,实现switch开关的ajax异步控制。
1下面是一个switch开关<span class="mui-badge "><div class="mui-switch" id="mySwitch1" data-off="关" data-on="开"><div class="mui-switch-handle"></div></div></span>2.对...原创 2018-09-07 15:50:01 · 1409 阅读 · 0 评论 -
SpringBoot的@controller类,实现ajax跨域的方法.
第一种直接在@Controller类下的方法里使用response.addHeader("Access-Control-Allow-Origin", "*");response.setHeader("Content-Type", "application/json;charset=UTF-8");如下:@GetMapping("/font")@ResponseBodypu...原创 2018-09-07 15:33:10 · 1126 阅读 · 0 评论 -
@Autowired,@Qualifier,@Resource的使用
@Autowired直接使用 @Autowired private UserMapper userMapper;@Qualifier需要与@Autowired一起使用,并在Qualifier写bean的name @Autowired @Qualifier("userMapper") private UserMapper userMapper;@...原创 2019-09-05 09:56:43 · 501 阅读 · 0 评论 -
springboot使用rabbitmq
添加依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId></dependency>application.yml配置:spring:...原创 2019-08-05 17:30:12 · 186 阅读 · 0 评论 -
springcloud配置统一配置中心
1配置config-server实现创建一个eureka client 见https://blog.youkuaiyun.com/qq_38522268/article/details/98465868添加依赖<dependency> <groupId>org.springframework.cloud</groupId> <artifac...原创 2019-08-05 16:33:50 · 224 阅读 · 0 评论 -
springboot多模块打成jar包
注意把以下配置放入启动类所在的pom文件中<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plu...原创 2019-08-05 13:42:43 · 2309 阅读 · 0 评论 -
springboot多模块重构
改变packaging方式<packaging>pom</packaging>注意依赖关系改变,需引入模块依赖<dependencies> <dependency> <groupId>com.example</groupId> <artifactId>...原创 2019-08-05 13:02:23 · 295 阅读 · 0 评论 -
springcloud集成feign
添加依赖<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> <version>1.4.2.RELEASE</version&...原创 2019-08-05 09:23:24 · 400 阅读 · 0 评论 -
springboot调用应用外的http
第一种:使用RestTemplateRestTemplate restTemplate = new RestTemplate();//http://115.28.179.114:8885/String reponse = restTemplate.getForObject("http://www.baidu.com", String.class);log.info(reponse);...原创 2019-08-04 21:36:32 · 599 阅读 · 0 评论 -
springcloud的eureka的应用名UNKNOWN
添加配置spring: application: name: name注意spring不要有多个,比如spring: application: name: namespring: datasource: driver-class-name: com.mysql.jdbc.Driver会显示应用名UNKNOWN,应sprin...原创 2019-08-04 19:39:11 · 1968 阅读 · 0 评论 -
springboot创建client
启动类加注解@EnableDiscoveryClient@SpringBootApplication@EnableDiscoveryClientpublic class ClientApplication { public static void main(String[] args) { SpringApplication.run(ClientAppli...原创 2019-08-04 14:05:14 · 710 阅读 · 0 评论 -
springboot+thymeleaf实现springsecurity
依赖:<!--Spring Security的依赖--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId></dependen...原创 2018-10-09 16:04:05 · 1974 阅读 · 1 评论 -
SpringBoot+Redis实现springsecurity
引入依赖:<!--redis--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId></dependency>c...原创 2018-10-09 17:36:10 · 5369 阅读 · 2 评论 -
springboot集成mybatis实现crud,并简单介绍mybatis的xml配置
mybatis无法像jpa一样自动建表,表需提前建好添加依赖<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dependency><!--mybatis-->&l...原创 2018-10-09 21:06:53 · 577 阅读 · 0 评论 -
Error creating bean with name 'blockChainService' defined in class path resource
定义BlockChainServiceConfig类时@Configurationpublic class BlockChainServiceConfig { @Bean BlockChainService blockChainService(){ return new BlockChainService(); }}BlockChainSe...原创 2019-02-18 14:03:04 · 434 阅读 · 0 评论 -
Springboot如何将一个未使用任何将该类注入Bean容器的注解,注入到bean容器中,并且能够在该类使用@Autowired的注解来调用其它类
通常我们使用JPA来操作mysql数据库时,会使用@Service来注解service类,这样我们就可以在使用@Controller注解的controller里使用@Autowired来调用service类下的方法但是在一些情况下我们不需要在一个类上@Service之类的注解而是使用@Configuration+@Bean把一个类注入到bean容器配置类@Configuratio...原创 2019-02-18 14:42:57 · 3995 阅读 · 0 评论 -
Springboot注入带参数的构造函数
我们使用@Service注解一个service,默认注入的是不带参的构造函数,如果我们需要注入带参的构造函数,怎么办?使用@Configuration+ @Bean注解来实现注入:@Configurationpublic class BlockChainServiceConfig { @Bean BlockChainService blockChainService(...原创 2019-02-18 14:56:16 · 31257 阅读 · 0 评论 -
Springboot报错Cloud not Autowired.No beans of 'int' type found.
Springboot下使用@Service注解 报错Cloud not Autowired.No beans of 'int' type found@Service 默认注解类的不带参数的构造器,当修饰带参的构造器 就会出现这样的报错如何解决,查看https://blog.youkuaiyun.com/qq_38522268/article/details/87620835...原创 2019-02-18 15:09:59 · 2561 阅读 · 0 评论 -
Springboot将含有多个构造器的类注入到bean容器,并实现区分对同一个类不同bean名称的 bean的区分的四种方法
service类有两个构造函数,一个不带参,一个带参public class BlockChainService { public BlockChainService() { System.out.println("不带参的构造器"); } public BlockChainService(int i) { System.o...原创 2019-02-18 16:14:27 · 7225 阅读 · 0 评论 -
springboot在redis里存放list并获取指定value
@Autowiredprivate StringRedisTemplate redisTemplate;@Test public void testRedisList() { redisTemplate.opsForList().rightPush("list", "one"); redisTemplate.opsForList().rightP...原创 2019-02-18 19:27:04 · 6836 阅读 · 0 评论 -
StringRedisTemplate 类下 redisTemplate.opsForList().remove(K var1, long var2, Object var4)用法
我在网上看到remove(Kkey, longcount,Objectvalue)从存储在键中的列表中删除等于值的元素的第一个计数事件。count> 0:删除等于从左到右移动的值的第一个元素;count< 0:删除等于从右到左移动的值的第一个元素;count = 0:删除等于value的所有元素。但我在测试时发现count<0时删除了整个list,c...原创 2019-02-18 19:35:01 · 15888 阅读 · 1 评论 -
Thymeleaf设置背景报错
我在网上看到<div th:style="'background:url(' + @{/<path-to-image>} + ');'"></div>这样设置背景,但是我在用时会报错后来我尝试这样:没有报错,背景也设置成功可能是因为thymelea版本的原因。我这边用的是2.1.1.RELEASE版本...原创 2019-03-12 17:19:31 · 4934 阅读 · 1 评论 -
thymeleaf如何下载网页上的图片
我这里会生产一个二维码,然后把该二维码下载下来<div th:if="${content} ne null"> <img th:src="@{/qrcode/create(content=${content})} "/> <br/> <a th:href="@{/qrcode/create(content=${content}...原创 2019-05-05 21:18:13 · 619 阅读 · 0 评论 -
freemaker无法加载静态资源
我在springboot中使用freemaker模板引擎,无法正确加载静态资源首先,确认静态资源没有被拦截器拦截后来发现是路径错了我在application.yml设置了server: servlet: context-path: /all所以在引用static资源时应<script src="/all/js/iconfont.js"><...原创 2019-05-06 09:52:48 · 693 阅读 · 0 评论