SpringBoot2.x重写configureMessageConverters()方法

经过对WebMvcConfigurationSupport的研究和无数次的 debug 跟踪,终于搞清楚了这个代码运行的各中逻辑,最后发现问题要得到完美解决,就加一句代码就搞定😂。 代码还是那个代码,只需在configureMessageConverters最后增加一句super.addDefaultHttpMessageConverters(converters); 就”完美”解决。  

java读取mysql表的注释及字段注释

java读取mysql表的注释及字段注释   /** * 读取mysql某数据库下表的注释信息 * * @author xxx */ public class MySQLTableComment { public static Connection getMySQLConnection() throws Exception { Class.forName(“com.mysql.jdbc.Driver”); Connection conn = DriverManager.getConnection(“jdbc:mysql://localhost:3306/databaseName”, “root”, “root”); return conn; } /** * 获取当前数据库下的所有表名称 * @return * @throws Exception */ public static List getAllTableName() throws Exception { List tables = new ArrayList(); Connection conn = … Read more

SpringBoot-单例中使用AutoWired

对于一个单例类按照平时的注解方式添加,启动时会报空指针异常,因为static类对象是创建对象后,内存中还没有注入Bean信息,且无法初始化Bean实例,这里的解决办法是利用@PostConstruct来对单例类中对象的注入。 @Component public class DBManager {     private static DBManager instance = new DBManager();     @Autowired     public UserServiceImpl userService;     private DBManager() {     }     public static DBManager getInstance() {         return instance;     }     @PostConstruct     public void init() {         instance = this;         instance.userService = this.userService;     } }

Mybatis批量插入或更新

1 批量更新 <foreach collection=”attendingUsrList” item=”model” separator=”;”> UPDATE parties SET attending_user_count = #{model.attending_count} WHERE fb_party_id = #{model.eid} </foreach> 2 批量插入 <insert id=”insertAccountabilityUsers” parameterType=”AccountabilityUsersModel” useGeneratedKeys=”false”> INSERT INTO accountability_users ( accountability_user_id, accountability_id, to_username, record_status, created_by, created_at, updated_by, updated_at ) VALUES <foreach collection=”usersList” item=”model” separator=”,”> ( #{model.accountabilityUserId}, #{model.accountabilityId}, #{model.toUsername}, ‘A’, #{model.createdBy}, #{model.createdAt}, #{model.updatedBy}, #{model.updatedAt} ) </foreach> </insert>

jQuery图表插件 jqPlot实现饼状图

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html lang=”en”> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″> <title>饼状图demo</title> <!–[if IE]><script language=”javascript” type=”text/javascript” src=”excanvas.js” ></script><![endif]–> <link rel=”stylesheet” type=”text/css” href=”jquery.jqplot.css” /> <script language=”javascript” type=”text/javascript” src=”jquery-1.4.2.min.js” ></script> <script language=”javascript” type=”text/javascript” src=”jquery.jqplot.js” ></script> <script language=”javascript” type=”text/javascript” src=”plugins/jqplot.pieRenderer.js” ></script> <script type=”text/javascript” language=”javascript”> $(document).ready(function(){ line1 = [[‘李开复’, 3], [‘周鸿祎’, 7], [‘李彦宏’, 2.5], [‘马化腾’, … Read more

jquery设置cookie、删除cookie、获取cookie

1.引入两个js 去bootcdn搜索就行。 jquery.js <script src=”https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js”></script> jquery cookie <script src=”https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js”></script> 2.设置cookie $.cookie(“key”,“value”); 如: $.cookie(“love”,“唱跳rap篮球”); //设置了一个值为”唱跳rap篮球的cookie,cookie的名字是love 3.给cookie设置时长 $.cookie(“key”,“value”,{expires: 7}) ;设置为7天 4.设置cookie的域名 在不同网页中是不能访问同一个cookie的,所以可以设置cookie的域名,让cookie在这个域名下都能访问。 $.cookie(“key”,“value”,{domain:“icyakuya.website”}) 5.设置cookie的路径 可以结合域名一起使用,在本地文件运行也能使用。 $.cookie(“key”,“value”,{domain:“icyakuya”,path:“xxx/”} path可以用过window.location.pathname 获取,这个获取到的是全路径包括文件名 所以需要做个截取: function getPath(){ var path = window.location.pathname; //获取的是文件路径全名包括路径 var pos = path.lastIndexOf(“/”); //去除文件名 path = path.substring(0, pos); return path; } 6.删除cookie $.removeCookie(‘key’,{path:”/”}) ;//删除该路径下所有名为key的cookie $.removeCookie(“key”,null,{path:”/”}) 将key的值设置为空,实际上相当于删除 7.获取cookie $.cookie(“name”) 注意: cookie的域名和路径都很重要,如果没有设置成一致,则会有不同域名下或者不同路径下的同名cookie,为了避免这种情况,建议在设置cookie和删除cookie的时候,配置路径和域名。 … Read more

JFinal框架

JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java语言所有优势的同时再拥… 官网: https://jfinal.com/