Java基础
文章平均质量分 56
李金麒君
学无止境,高山仰止
展开
-
一个接口多个实现报错时不使用@Primary和@Qualifier注解的解决方案
一个接口多个实现报错时不使用@Primary和@Qualifier注解的解决方案有时候在写接口实现时,会有多个实现类的情况。但是在项目启动时报错,因为springboot不知道要注入哪个bean,在网上看了许多的解决方案,基本都是是使用@Primary注解和@Qualifier注解,本篇文章另辟蹊径找到一个解决了该问题。1.创建一个接口public interface TestService { public void method();}实现类TestServiceImpl1,@Or原创 2021-02-03 12:11:48 · 818 阅读 · 0 评论 -
使用拦截器切换多数据源
拦截器多数据源切换公司项目升级,由原来的单数据源改为多数据源,一个数据库存放公共数据,一个数据存放特殊数据,住其中就需要使用到数据库的切换,项目做完后就把数据库切换的基本实现逻辑记录先来,以供以后查看配置application。yamlspring: datasource: master: url: ${SPRING_DATASOURCE_URL:jdbc:mysql://192.168.100.11:3306/wf_platform?useUnicode=true&原创 2021-02-02 10:33:36 · 2793 阅读 · 0 评论 -
mysql创建索引时判断索引是否存在
mysql创建索引时判断缩影是否存在drop procedure if exists schema_change;delimiter //create procedure schema_change() begindeclare currentdatabase varchar(100);select database() into currentdatabase;if not exists (select * from information_schema.statistics where t原创 2020-11-25 17:42:13 · 1703 阅读 · 0 评论 -
Servlet.service() for servlet [dispatcherServlet] in context with path []错误
做springboot项目对token认证时,在application.properties做了配置token: tokenHeader: access-token tokenSecret: 86f3d82fed2348f49b38ec86c1f2fed2@Data@Configuration@ConfigurationProperties(prefix = "token")public class TokenAuthenticationProperties { private原创 2020-11-14 15:56:04 · 21260 阅读 · 0 评论 -
java数组排序
冒泡排序public static void main(String[] args){ int[] arr = {30,18,32,50,92,79,26,77,101,8,3,1,41}; for (int i = 0; i < arr.length - 1; i++) { // 外层循环控制排序趟数 for (int j = 0; j < arr.length - i - 1; j++) { // //内层循环控制每一趟排序多少次 if (arr[j+1] < a转载 2020-08-05 16:41:01 · 103 阅读 · 0 评论 -
java求一组数据的各自所占百分比
由于项目需要求出一组数据各占的百分比,可能有朋友也会遇到,所以分享给各位,希望对各位有帮助非常简单,直接上代码public static void main(String[] args) { int[] arr = {43,28,15,79}; String[] str = new String[arr.length]; NumberFormat instance = NumberFormat.getInstance(); // 保留小数点原创 2020-07-31 14:52:02 · 2069 阅读 · 0 评论