All posts by 龙生
MYSQL设置触发器权限问题的解决方法
本文实例讲述了MYSQL设置触发器权限的方法,针对权限错误的情况非常实用。具体分析如下: mysql导入数据提示没有SUPER Privilege权限处理,如下所示:
1 |
ERROR 1419 (HY000): You do not have the SUPER Privilege and Binary Logging is Enabled |
导入function 、 trigger 到 MySQL database,报错:
1 |
You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)”. |
原因: function / trigger 中有dangerous statements修改数据库,错误只在启用binary logging选项进行主从复制的服务器上出现。 解决方法如下: 1)导入数据的用户不仅需要CREATE ROUTINE, ALTER ROUTINE, CREATE TRIGGER, ALTER TRIGGER, CREATE FUNCTION 和 ALTER FUNCTION 权限,还需要SUPER privileges 权限,使用超级用户导入数据。 2)让所有用户具有执行类似functions的权限,危险,不推荐,
1 2 3 |
o by specifying it on the server start, like: –log-bin-trust-function-creators=1 o by setting it to 1 through the SET GLOBAL statement, like: mysql> SET GLOBAL log_bin_trust_function_creators = 1; |
3)如果不需要复制,或者是从库,关闭binlog,
1 2 3 4 |
# binary logging – not required for slaves, but recommended #log-bin=mysql-bin # binary logging format – mixed recommended #binlog_format=mixed |
希望本文所述对大家的MySQL数据库设计有所帮助。 from:https://www.jb51.net/article/54635.htm
View DetailsCentOS7上安装Docker
Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE。
社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施、容器、插件等。
社区版按照stable和edge两种方式发布,每个季度更新stable版本,如17.06,17.09;每个月份更新edge版本,如17.09,17.10。
领导:谁再用定时任务实现关闭订单,立马滚蛋!
在电商、支付等领域,往往会有这样的场景,用户下单后放弃支付了,那这笔订单会在指定的时间段后进行关闭操作,细心的你一定发现了像某宝、某东都有这样的逻辑,而且时间很准确,误差在1s内;那他们是怎么实现的呢? 一般的做法有如下几种 定时任务关闭订单 rocketmq延迟队列 rabbitmq死信队列 时间轮算法 redis过期监听 一、定时任务关闭订单(最low) 一般情况下,最不推荐的方式就是关单方式就是定时任务方式,原因我们可以看下面的图来说明 我们假设,关单时间为下单后10分钟,定时任务间隔也是10分钟;通过上图我们看出,如果在第1分钟下单,在第20分钟的时候才能被扫描到执行关单操作,这样误差达到10分钟,这在很多场景下是不可接受的,另外需要频繁扫描主订单号造成网络IO和磁盘IO的消耗,对实时交易造成一定的冲击,所以PASS 二、rocketmq延迟队列方式 延迟消息 生产者把消息发送到消息服务器后,并不希望被立即消费,而是等待指定时间后才可以被消费者消费,这类消息通常被称为延迟消息。 在RocketMQ开源版本中,支持延迟消息,但是不支持任意时间精度的延迟消息,只支持特定级别的延迟消息。 消息延迟级别分别为1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h,共18个级别。 发送延迟消息(生产者)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/** * 推送延迟消息 * @param topic * @param body * @param producerGroup * @return boolean */ public boolean sendMessage(String topic, String body, String producerGroup) { try { Message recordMsg = new Message(topic, body.getBytes()); producer.setProducerGroup(producerGroup); //设置消息延迟级别,我这里设置14,对应就是延时10分钟 // "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h" recordMsg.setDelayTimeLevel(14); // 发送消息到一个Broker SendResult sendResult = producer.send(recordMsg); // 通过sendResult返回消息是否成功送达 log.info("发送延迟消息结果:======sendResult:{}", sendResult); DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); log.info("发送时间:{}", format.format(new Date())); return true; } catch (Exception e) { e.printStackTrace(); log.error("延迟消息队列推送消息异常:{},推送内容:{}", e.getMessage(), body); } return false; } |
消费延迟消息(消费者)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
/** * 接收延迟消息 * * @param topic * @param consumerGroup * @param messageHandler */ public void messageListener(String topic, String consumerGroup, MessageListenerConcurrently messageHandler) { ThreadPoolUtil.execute(() -> { try { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(); consumer.setConsumerGroup(consumerGroup); consumer.setVipChannelEnabled(false); consumer.setNamesrvAddr(address); //设置消费者拉取消息的策略,*表示消费该topic下的所有消息,也可以指定tag进行消息过滤 consumer.subscribe(topic, "*"); //消费者端启动消息监听,一旦生产者发送消息被监听到,就打印消息,和rabbitmq中的handlerDelivery类似 consumer.registerMessageListener(messageHandler); consumer.start(); log.info("启动延迟消息队列监听成功:" + topic); } catch (MQClientException e) { log.error("启动延迟消息队列监听失败:{}", e.getErrorMessage()); System.exit(1); } }); } |
实现监听类,处理具体逻辑
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/** * 延迟消息监听 * */ @Component public class CourseOrderTimeoutListener implements ApplicationListener<ApplicationReadyEvent> { @Resource private MQUtil mqUtil; @Resource private CourseOrderTimeoutHandler courseOrderTimeoutHandler; @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { // 订单超时监听 mqUtil.messageListener(EnumTopic.ORDER_TIMEOUT, EnumGroup.ORDER_TIMEOUT_GROUP, courseOrderTimeoutHandler); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/** * 实现监听 */ @Slf4j @Component public class CourseOrderTimeoutHandler implements MessageListenerConcurrently { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext consumeConcurrentlyContext) { for (MessageExt msg : list) { // 得到消息体 String body = new String(msg.getBody()); JSONObject userJson = JSONObject.parseObject(body); TCourseBuy courseBuyDetails = JSON.toJavaObject(userJson, TCourseBuy.class); // 处理具体的业务逻辑,,,,, DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); log.info("消费时间:{}", format.format(new Date())); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } } |
这种方式相比定时任务好了很多,但是有一个致命的缺点,就是延迟等级只有18种(商业版本支持自定义时间),如果我们想把关闭订单时间设置在15分钟该如何处理呢?显然不够灵活。 三、rabbitmq死信队列的方式 Rabbitmq本身是没有延迟队列的,只能通过Rabbitmq本身队列的特性来实现,想要Rabbitmq实现延迟队列,需要使用Rabbitmq的死信交换机(Exchange)和消息的存活时间TTL(Time To Live) 死信交换机 一个消息在满足如下条件下,会进死信交换机,记住这里是交换机而不是队列,一个交换机可以对应很多队列。 一个消息被Consumer拒收了,并且reject方法的参数里requeue是false。也就是说不会被再次放在队列里,被其他消费者使用。 上面的消息的TTL到了,消息过期了。 队列的长度限制满了。排在前面的消息会被丢弃或者扔到死信路由上。 死信交换机就是普通的交换机,只是因为我们把过期的消息扔进去,所以叫死信交换机,并不是说死信交换机是某种特定的交换机 消息TTL(消息存活时间) 消息的TTL就是消息的存活时间。RabbitMQ可以对队列和消息分别设置TTL。对队列设置就是队列没有消费者连着的保留时间,也可以对每一个单独的消息做单独的设置。超过了这个时间,我们认为这个消息就死了,称之为死信。如果队列设置了,消息也设置了,那么会取值较小的。所以一个消息如果被路由到不同的队列中,这个消息死亡的时间有可能不一样(不同的队列设置)。这里单讲单个消息的TTL,因为它才是实现延迟任务的关键。
1 2 3 4 |
byte[] messageBodyBytes = "Hello, world!".getBytes(); AMQP.BasicProperties properties = new AMQP.BasicProperties(); properties.setExpiration("60000"); channel.basicPublish("my-exchange", "queue-key", properties, messageBodyBytes); |
可以通过设置消息的expiration字段或者x-message-ttl属性来设置时间,两者是一样的效果。只是expiration字段是字符串参数,所以要写个int类型的字符串:当上面的消息扔到队列中后,过了60秒,如果没有被消费,它就死了。不会被消费者消费到。这个消息后面的,没有“死掉”的消息对顶上来,被消费者消费。死信在队列中并不会被删除和释放,它会被统计到队列的消息数中去 处理流程图 创建交换机(Exchanges)和队列(Queues) 创建死信交换机 如图所示,就是创建一个普通的交换机,这里为了方便区分,把交换机的名字取为:delay 创建自动过期消息队列 这个队列的主要作用是让消息定时过期的,比如我们需要2小时候关闭订单,我们就需要把消息放进这个队列里面,把消息过期时间设置为2小时 创建一个一个名为delay_queue1的自动过期的队列,当然图片上面的参数并不会让消息自动过期,因为我们并没有设置x-message-ttl参数,如果整个队列的消息有消息都是相同的,可以设置,这里为了灵活,所以并没有设置,另外两个参数x-dead-letter-exchange代表消息过期后,消息要进入的交换机,这里配置的是delay,也就是死信交换机,x-dead-letter-routing-key是配置消息过期后,进入死信交换机的routing-key,跟发送消息的routing-key一个道理,根据这个key将消息放入不同的队列 创建消息处理队列 这个队列才是真正处理消息的队列,所有进入这个队列的消息都会被处理 消息队列的名字为delay_queue2 消息队列绑定到交换机 进入交换机详情页面,将创建的2个队列(delayqueue1和delayqueue2)绑定到交换机上面 自动过期消息队列的routing key 设置为delay 绑定delayqueue2 delayqueue2 的key要设置为创建自动过期的队列的x-dead-letter-routing-key参数,这样当消息过期的时候就可以自动把消息放入delay_queue2这个队列中了 绑定后的管理页面如下图: 当然这个绑定也可以使用代码来实现,只是为了直观表现,所以本文使用的管理平台来操作 发送消息
1 2 3 4 5 6 |
String msg = "hello word"; MessageProperties messageProperties = newMessageProperties(); messageProperties.setExpiration("6000"); messageProperties.setCorrelationId(UUID.randomUUID().toString().getBytes()); Message message = newMessage(msg.getBytes(), messageProperties); rabbitTemplate.convertAndSend("delay", "delay",message); |
设置了让消息6秒后过期 注意:因为要让消息自动过期,所以一定不能设置delay_queue1的监听,不能让这个队列里面的消息被接受到,否则消息一旦被消费,就不存在过期了 接收消息 接收消息配置好delay_queue2的监听就好了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
package wang.raye.rabbitmq.demo1; import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.DirectExchange; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration publicclassDelayQueue{ /** 消息交换机的名字*/ publicstaticfinalString EXCHANGE = "delay"; /** 队列key1*/ publicstaticfinalString ROUTINGKEY1 = "delay"; /** 队列key2*/ publicstaticfinalString ROUTINGKEY2 = "delay_key"; /** * 配置链接信息 * @return */ @Bean publicConnectionFactory connectionFactory() { CachingConnectionFactory connectionFactory = newCachingConnectionFactory("120.76.237.8",5672); connectionFactory.setUsername("kberp"); connectionFactory.setPassword("kberp"); connectionFactory.setVirtualHost("/"); connectionFactory.setPublisherConfirms(true); // 必须要设置 return connectionFactory; } /** * 配置消息交换机 * 针对消费者配置 FanoutExchange: 将消息分发到所有的绑定队列,无routingkey的概念 HeadersExchange :通过添加属性key-value匹配 DirectExchange:按照routingkey分发到指定队列 TopicExchange:多关键字匹配 */ @Bean publicDirectExchange defaultExchange() { returnnewDirectExchange(EXCHANGE, true, false); } /** * 配置消息队列2 * 针对消费者配置 * @return */ @Bean publicQueue queue() { returnnewQueue("delay_queue2", true); //队列持久 } /** * 将消息队列2与交换机绑定 * 针对消费者配置 * @return */ @Bean @Autowired publicBinding binding() { returnBindingBuilder.bind(queue()).to(defaultExchange()).with(DelayQueue.ROUTINGKEY2); } /** * 接受消息的监听,这个监听会接受消息队列1的消息 * 针对消费者配置 * @return */ @Bean @Autowired publicSimpleMessageListenerContainer messageContainer2(ConnectionFactory connectionFactory) { SimpleMessageListenerContainer container = newSimpleMessageListenerContainer(connectionFactory()); container.setQueues(queue()); container.setExposeListenerChannel(true); container.setMaxConcurrentConsumers(1); container.setConcurrentConsumers(1); container.setAcknowledgeMode(AcknowledgeMode.MANUAL); //设置确认模式手工确认 container.setMessageListener(newChannelAwareMessageListener() { publicvoid onMessage(Message message, com.rabbitmq.client.Channel channel) throwsException{ byte[] body = message.getBody(); System.out.println("delay_queue2 收到消息 : "+ newString(body)); channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); //确认消息成功消费 } }); return container; } } |
[…]
View Details@RequestMapping 使用详解
这一节虽然简单,但是很繁琐,可以先了解 @RequestMapping 的使用,不是很明白也没有关系,先继续往下学习,等你回头再看一遍的时候,你会发现 @RequestMapping 竟然是如此的简单! @RequestMapping可以在控制器类上或者控制器方法上使用。 在类的级别上的注解会将一个特定请求或者请求模式映射到一个控制器之上。之后你还可以另外添加方法级别的注解来进一步指定到处理方法的映射关系。 基础用法: 下面的 @RequestMapping("/index") 等同于 @RequestMapping(value = "/index")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/index") public class HelloWorldController { @RequestMapping(value = "/hello", method = RequestMethod.GET) public String hello() { return "/WEB-INF/views/success.jsp"; } @RequestMapping(value = "/world", method = RequestMethod.POST) public String world() { return "/WEB-INF/views/success.jsp"; } } |
method 参数支持:GET, PUT, POST, DELETE 以及 PATCH。使用 method 可以限制接受的请求类型。 hello() 方法将只接受请求方式为 GET 方式,请求地址为:/index/hello 的请求。 world() 方法将只接受请求方式为 POST 方式,请求地址为:/index/world 的请求。 @GetMapping("/hello") 等同于 @RequestMapping(value="/hello", method=RequestMethod.GET) @PostMapping("/world") 等同于 @RequestMapping(value="/world", method=RequestMethod.POST) 映射多个地址: @RequestMapping 还可以将多个请求映射到一个方法上,只需要给 value 来指定一个包含多个路径的列表。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/index") public class HelloWorldController { @RequestMapping(value = {"/hello", "/world", "/helloworld"}) public String hello() { return "/WEB-INF/views/success.jsp"; } } |
URI模板: URI模板可以为快速访问 @RequestMapping 中指定的URL的一个特定的部分提供很大的便利。 使用 @PathVariable 可以获取到 {name} 的值,并在控制台进行输出。比如请求地址为:http://localhost:8080/SpringMVC/hello/jack 那么控制台上将会把 jack 进行输出。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { @RequestMapping("/hello/{name}") public String hello(@PathVariable String name) { System.out.println(name); return "/WEB-INF/views/success.jsp"; } } |
如果路径中的URI变量和方法中的参数名不一样的话,那么需要在 @PathVariable 中显示的绑定参数。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { @RequestMapping("/hello/{name}") public String hello(@PathVariable("name") String username) { System.out.println(username); return "/WEB-INF/views/success.jsp"; } } |
一个方法可以拥有任意数量的 @PathVariable 注解:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { @RequestMapping("/hello/{name}/age/{age}") public String hello(@PathVariable String name, @PathVariable int age) { System.out.println("name:" + name + ",age:" + age); return "/WEB-INF/views/success.jsp"; } } |
@PathVariable 可以被应用于所有 简单类型 的参数上,比如 int、long、Date 等类型。Spring会自动地帮你把参数转化成合适的类型,如果转换失败,就抛出一个 TypeMismatchException。如果你需要处理其他数据类型的转换,也可以注册自己的类。 带正则表达式的URI模板: 你可以使用正则表达式来准确的描述可以接受的请求路径:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { @RequestMapping("/hello/{name:[a-z]+}/age/{age}") public String hello(@PathVariable String name, @PathVariable int age) { System.out.println("name:" + name + ",age:" + age); return "/WEB-INF/views/success.jsp"; } } |
Ant风格的路径模式: 除了URI模板外,@RequestMapping注解还支持Ant风格的路径模式(如/hello/*.do等)。不仅如此,还可以把URI模板变量和Ant风格的glob组合起来使用(比如/hello/*/user/{userId}这样的用法等)。其中*则表示任意字符串。但是遇到 / 那么就会认为是下一部分的URI,所以 * 中不能有 / 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { // 匹配的地址:http://localhost:8080/SpringMVC/hello/jack/user/18 @RequestMapping("/hello/*/user/{userId}") public String hello(@PathVariable String userId) { System.out.println(userId); return "/WEB-INF/views/success.jsp"; } } |
那么想要匹配带 / 的路径那该怎么办?可以使用 ** 来进行匹配。例如 /hello/**/user/{userId} 则会匹配 /hello/ 和 /user/{userId} 之间的部分。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
package com.pudding.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloWorldController { // 匹配的地址:http://localhost:8080/SpringMVC/hello/jack/tom/cat/user/18 @RequestMapping("/hello/**/user/{userId}") public String hello(@PathVariable String userId) { System.out.println(userId); return "/WEB-INF/views/success.jsp"; } } |
路径样式的匹配(Path Pattern Comparison): 当一个URL同时匹配多个模板(pattern)时,我们将需要一个算法来决定其中最匹配的一个。 URI模板变量的数目和通配符数量的总和最少的那个路径模板更准确。举个例子,/hotels/{hotel}/*这个路径拥有一个URI变量和一个通配符,而/hotels/{hotel}/**这个路径则拥有一个URI变量和两个通配符,因此,我们认为前者是更准确的路径模板。 如果两个模板的URI模板数量和通配符数量总和一致,则路径更长的那个模板更准确。举个例子,/foo/bar*就被认为比/foo/*更准确,因为前者的路径更长。 如果两个模板的数量和长度均一致,则那个具有更少通配符的模板是更加准确的。比如,/hotels/{hotel}就比/hotels/*更精确。 […]
View Details2021 年度 OSC 中国开源项目评选:OSCHINA 人气指数 TOP 50 开源项目公布
经过两周的角逐,2021 年度 OSC 中国开源项目评选第一轮投票已结束。 本次评选对「组织」和「个人」的开源项目进行了区分,并针对「组织」通道的项目设置了 7 大分类:基础软件、云原生、大前端、DevOps、开发框架与工具、AI & 大数据、IoT & 5G 。 第一轮投票根据票数选出「组织」项目 7 大分类中每个分类的 TOP 5,以及「个人」项目的 TOP 15,总共 50 个项目获得「OSCHINA 人气指数 TOP 50 开源项目」称号。 「组织」通道获奖项目(35 个) 「个人」通道获奖项目(15 个) 恭喜以上项目获得「OSCHINA 人气指数 TOP 50 开源项目」称号,它们将继续参与第二轮投票环节以争夺「最受欢迎项目」奖项,欢迎大家前来投票支持 ↓↓↓ https://www.oschina.net/project/top_cn_2021 from:https://www.oschina.net/question/2918182_2324736
View Details解决IDEA2021版compiler.automake.allow.when.app.running不存在的问题
IntelliJ IDEA 简称 IDEA,被业界公认为最好的 Java 集成开发工具,尤其在智能代码助手、代码自动提示、代码重构、代码版本管理(Git、SVN、Maven)、单元测试、代码分析等方面有着亮眼的发挥。IDEA 产于捷克,开发人员以严谨著称的东欧程序员为主。IDEA 分为社区版和付费版两个版本。 idea2021免费激活教程: https://www.jb51.net/article/195962.htm https://www.jb51.net/article/196349.htm 下面开始今天的正文介绍: 很多文章介绍IntelliJ IDEA开启热部署功能都会写到在IntelliJ IDEA中的注册表中开启compiler.automake.allow.when.app.running选项,此选项在IntelliJ IDEA 2021.2之后的版本迁移到高级设置中。如下图所示: 如果你安装了中文语言包,那么它在这里 到此这篇关于解决IDEA2021版compiler.automake.allow.when.app.running不存在的问题的文章就介绍到这了,更多相关idea2021compiler.automake.allow.when.app.running不存在内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家! from:https://www.jb51.net/article/223927.htm
View Detailsdocker: Error response from daemon: driver failed programming external connectivity on endpoint lamp
Docker容器做端口映射报错 docker: Error response from daemon: driver failed programming external connectivity on endpoint lamp3 (46b7917c940f7358948e55ec2df69a4dec2c6c7071b002bd374e8dbf0d40022c): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 86 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name. 解决方法 docker服务启动时定义的自定义链DOCKER被清除 重启即可
1 |
systemctl restart docker |
———————————————— 版权声明:本文为CSDN博主「米粥粥」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_41545647/article/details/102679560
View DetailsGit教程 — 使用git stash保存和恢复进度
当正在dev分支上开发某个项目,这时项目中出现一个bug,需要紧急修复,但是正在开发的内容只是完成一半,还不想提交,这时可以用git stash命令将修改的内容保存至堆栈区,然后顺利切换到hotfix分支进行bug修复,修复完成后,再次切回到dev分支,从堆栈中恢复刚刚保存的内容。
View DetailsJava日志框架SLF4J和log4j以及logback的联系和区别
1.SLF4J(Simple logging Facade for Java) 意思为简单日志门面,它是把不同的日志系统的实现进行了具体的抽象化,只提供了统一的日志使用接口,使用时只需要按照其提供的接口方法进行调用即可,由于它只是一个接口,并不是一个具体的可以直接单独使用的日志框架,所以最终日志的格式、记录级别、输出方式等都要通过接口绑定的具体的日志系统来实现,这些具体的日志系统就有log4j,logback,java.util.logging等,它们才实现了具体的日志系统的功能。 如何使用SLF4J? 既然SLF4J只是一个接口,那么实际使用时必须要结合具体的日志系统来使用,我们首先来看SLF4J和各个具体的日志系统进行绑定时的框架原理图: 其实slf4j原理很简单,他只提供一个核心slf4j api(就是slf4j-api.jar包),这个包只有日志的接口,并没有实现,所以如果要使用就得再给它提供一个实现了些接口的日志包,比 如:log4j,common logging,jdk log日志实现包等,但是这些日志实现又不能通过接口直接调用,实现上他们根本就和slf4j-api不一致,因此slf4j又增加了一层来转换各日志实现包的使 用,当然slf4j-simple除外。其结构如下: slf4j-api(接口层) | 各日志实现包的连接层( slf4j-jdk14, slf4j-log4j) | 各日志实现包 所以,结合各日志实现包使用时提供的jar包情况为: SLF4J和logback结合使用时需要提供的jar:slf4j-api.jar,logback-classic.jar,logback-core.jar SLF4J和log4j结合使用时需要提供的jar:slf4j-api.jar,slf4j-log412.jar,log4j.jar SLF4J和JDK中java.util.logging结合使用时需要提供的jar:slf4j-api.jar,slf4j-jdk14.jar SLF4J和simple(SLF4J本身提供的一个接口的简单实现)结合使用时需要提供的jar:slf4j-api.jar,slf4j-simple.jar 当然还有其他的日志实现包,以上是经常会使用到的一些。 注意,以上slf4j和各日志实现包结合使用时最好只使用一种结合,不然的话会提示重复绑定日志,并且会导致日志无法输出。 slf4j-api.jar:对外提供统一的日志调用接口,该接口具体提供的调用方式和方法举例说明: public class Test { private static final Logger logger = LoggerFactory.getLogger(Tester.class); //通过LoggerFactory获取Logger实例 public static void main(String[] args) { //接口里的统一的调用方法,各具体的日志系统都有实现这些方法 logger.info("testlog: {}", "test"); logger.debug("testlog: {}", "test"); logger.error("testlog: {}", "test"); logger.trace("testlog: {}", "test"); logger.warn("testlog: {}", "test"); } } 如果系统中之前已经使用了log4j做日志输出,想使用slf4j作为统一的日志输出,该怎么办呢? 如果之前系统中是单独使用log4j做为日志输出的,这时再想使用slf4j做为日志输出时,如果系统中日志比较多,此时更改日志输出方法肯定是不太现实的,这个时候就可以使用log4j-over-slf4j.jar将使用log4j日志框架输出的日志路由到slf4j上来统一采用slf4j来输出日志。 为什么要使用SLF4J? slf4j是一个日志接口,自己没有具体实现日志系统,只提供了一组标准的调用api,这样将调用和具体的日志实现分离,使用slf4j后有利于根据自己实际的需求更换具体的日志系统,比如,之前使用的具体的日志系统为log4j,想更换为logback时,只需要删除log4j相关的jar,然后加入logback相关的jar和日志配置文件即可,而不需要改动具体的日志输出方法,试想如果没有采用这种方式,当你的系统中日志输出有成千上万条时,你要更换日志系统将是多么庞大的一项工程。如果你开发的是一个面向公众使用的组件或公共服务模块,那么一定要使用slf4的这种形式,这有利于别人在调用你的模块时保持和他系统中使用统一的日志输出。 slf4j日志输出时可以使用{}占位符,如,logger.info("testlog: {}", "test"),而如果只使用log4j做日志输出时,只能以logger.info("testlog:"+"test")这种形式,前者要比后者在性能上更好,后者采用+连接字符串时就是new 一个String 字符串,在性能上就不如前者。 2.log4j(log for java) Log4j是Apache的一个开源项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台、文件、GUI组件,甚至是套接口服务器、NT的事件记录器、UNIX Syslog守护进程等;我们也可以控制每一条日志的输出格式;通过定义每一条日志信息的级别,我们能够更加细致地控制日志的生成过程。最令人感兴趣的就是,这些可以通过一个配置文件来灵活地进行配置,而不需要修改应用的代码。 如何使用? 引入jar,使用log4j时需要的jar为:log4j.jar。 定义配置文件log4j.properties或log4j.xml 在具体的类中进行使用: 在需要日志输出的类中加入:private static final Logger logger = Logger.getLogger(Tester.class); //通过Logger获取Logger实例 在需要输出日志的地方调用相应方法即可:logger.debug(“System […]
View Details【破解APP抓包限制】Xposed+JustTrustMe关闭SSL证书验证!
1 前言 这篇文章主要想解决的问题是,在对安卓手机APP抓包时,出现的HTTPS报文通过MITM代理后证书不被信任的问题。(工作中在抓取12306请求时就遇到了这个问题) 之前的推送讲过,通常要抓取HTTPS加密的数据包,一般使用Charles或者Fiddler4代理HTTP请求,配置证书信任后,便可拿到明文报文。但是由于Charles证书和Fiddler证书并非证书机构颁发的目标站点的合法证书,所以会不被信任。同样的道理,之前说过的神器Packet Capture也存在该问题。 对使用Charles等工具进行中间人代理抓取HTTPS请求不会的请看之前的推送: 阅读下文来解决这个问题。 2 解决方案 要解决这个问题要使用的工具是:Xposed+JustTrustMe (安卓手机需要Root,该方法有手机变砖风险,建议在模拟器下操作) XposedInstaller(xposed框架)是一款可以在不修改APK的情况下影响程序运行(修改系统)的框架服务,基于它可以制作出许多功能强大的模块,且在功能不冲突的情况下同时运作。 JustTrustMe是Github上的一个开源工程,他是一个Xposed模块,用来禁止SSL证书验证。以下是其简介。 JustTrustMe:An xposed module that disables SSL certificate checking. This is useful for auditing an appplication which does certificate pinning. Xposed安装器下载地址 安卓5.0版本以下下载地址:https://pan.baidu.com/s/1dEToAvJ 密码:uiu8 安卓5.0版本以上下载地址:https://files.cnblogs.com/files/pingming/xposedinstaller.apk JustTrustMe Relese版本下载地址:https://files.cnblogs.com/files/pingming/JustTrustMe.apk github:https://github.com/Fuzion24/JustTrustMe/releases 以下是安装步骤: 1 安装Xposed安装器 2 安装Xposed框架 安装过程需要Root权限,完成后重启。 3 安装JustTrustMe 4 安装完成后打开模块选项 勾选JustTrustMe,重启即可。 至此,完成配置,再加上之前的Charles或者Fiddler4的HTTPS配置,就能抓取HTTPS请求了。 3 最后 最后再强调一次,安装Xposed是有风险的,请尽量在模拟器中操作。 文中的Xposed下载链接主要是针对于安卓5.0以下的机器,是在夜神模拟器安卓4.4版本测试通过,其他版本使用大同小异,请自行查找合适版本安装使用。 from:https://www.cnblogs.com/pingming/p/10846068.html
View Details