
java
文章平均质量分 51
会_飞_的猪
这个作者很懒,什么都没留下…
展开
-
RocketMQ面试题及答案
4.Produce发送消息,启动共时先跟nameServer集群中的其中一台建立长连接,并从nameServer中获取路由信息,即当前发送的Topic消息的queue与broleer的地址的映射关系,然后根据算法策略从队列选择一个queue,与队列所在的Broker建立长连接,从而向broker发送消息,当然,在获取到路由信息后,producer会首先将路由信息缓存到本地,再每30秒从nameServer更新一次路由信息。master宕机了还有slave中的消息可用,保证了mq的可靠性和高可用性。原创 2023-02-21 21:55:02 · 1879 阅读 · 0 评论 -
Springboot 调用mysql的.sql文件,执行mysql语句
代码:import org.springframework.beans.factory.annotation.Value;import org.springframework.core.io.ClassPathResource;import org.springframework.core.io.support.EncodedResource;import org.springframework.jdbc.datasource.init.ScriptUtils;import org.springf原创 2021-10-16 17:43:42 · 491 阅读 · 0 评论 -
泛型与 反射 给字段赋值
/** * 该类主要用于反射赋值, * t1 取值类 * t2 赋值类 * reflection t1与t2的对应关系 如: String str = "xref1:scNo,xref2:scName,xref3:dutyEmp"; 即将 t1 中 scNo 赋值给 t2 中 xref1 * 对应关系必须是两个对象中的字段, 区分 大小写 */@Service("ReflectionServiceImpl")public class ReflectionServiceImpl implem原创 2021-04-17 10:30:16 · 681 阅读 · 0 评论 -
Oracle 在批量插入时报nested exception is java.sql.SQLException: sql injection violation
Oracle 使用 druid 时,由于版本过低(1.0.16)报 nested exception is java.sql.SQLException: sql injection violation, class com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleBlockStatement not allow批量插入数据:<insert id="11111" parameterType="java.util.ArrayList">原创 2021-04-10 17:12:21 · 1336 阅读 · 0 评论 -
Spring Boot 项目启动时加载数据
Spring Boot 项目启动时加载数据主要就是一个注解@PostConstruct ,该注解被用来修饰一个非静态的void()方法。被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器执行一次。PostConstruct在构造函数之后执行,init()方法之前执行。@PostConstruct public void init(){ for (int i = 0 ; i < 50; i++){ System.out.println("项目原创 2020-10-17 09:38:38 · 502 阅读 · 0 评论 -
Spring Boot 中 线程 使用 @Autowired 注入 报空指针
Spring Boot 中 线程 使用 @Autowired 注入 报空指针在springBoot中另起一个线程,在使用@Autowired 自动注入时, spring并不会将其注入,此刻需要自己手动从 bean工厂中获取 , 需要重新写一个 utils类 , 如下 :import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.spri原创 2020-10-17 09:37:41 · 749 阅读 · 1 评论 -
StopWatch 监控时间用法
StopWatch 监控时间用法// stopWatch 引入的jar包 org.springframework.util.StopWatch// start 与 stop 是一一对应的, 如果想要在start与 stop中监控其他内容耗时,此时需要重新创建一个对象. // 不允许在同一个对象中连续start 两次, 否则会抛出异常(IllegalStateException)try{ Long sTime = System.currentTimeMillis();原创 2020-10-17 09:22:18 · 917 阅读 · 0 评论