15
2020.09 问题总结(Oracle-->MySQL、Maven、JSP-->Thymeleaf、Druid)
source link: http://www.cnblogs.com/l1ng14/p/13754012.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
2020.09 问题总结(Oracle-->MySQL、Maven、JSP-->Thymeleaf、Druid)
数据库建表
Oracle 转 MySQL 问题
Oracle
MySQL
可变字符
varchar2
varchar
自增 id
default SYS_GUID()
CREATE TRIGGER product_before_insert
BEFORE INSERT ON product
FOR EACH ROW BEGIN
IF new.id is NULL THEN
SET new.id = UUID();
END IF;
END; 字符串转
timestamp
to_timestamp('10-10-2018 10:10:00.000000', 'dd-mm-yyyy hh24:mi:ss.ff'),
TIMESTAMP('2018-12-25 10:18:00.000000')
Maven模块化构建工程
The POM for com.food:food-manager-pojo:jar:0.0.1-SNAPSHOOT is missing, no dependency informat
搭建完所有子工程后,在 Maven
父工程处,点击 install
完成工程构建:
Thymeleaf 替换 JSP
超链接及静态资源使用:
<!-- 超链接: --> <a th:href="@{/pages/main}"> <!--静态资源: --> <img th:src="@{/img/center.jpg}">
重用模板片段:
提取模板片段作为单个页面(不同于 JSP
不提取也是可以的)
<html xmlns:th="http://www.thymeleaf.org"> <!-- 页面头部 --> <header class="main-header" th:fragment="header"> ... </header> </html>
<html xmlns:th="http://www.thymeleaf.org"> <!-- 导航侧栏 --> <aside class="main-sidebar" th:fragment="aside"> ... </aside> </html>
需要使用模板片段的,
-
采用
th:insert
的方法
<!-- 页面头部 --> <div th:insert="~{pages/header.html::header}"></div> <!-- 页面头部 /--> <!-- 导航侧栏 --> <div th:insert="~{pages/aside.html::aside}"></div>
-
还可以使用
th:replace
和th:include
属性插入。
文本输入
<span th:text="This is prototype text002.">This is prototype text.</span>
使用变量
<span th:text="${userName}">This is prototype text.</span>
迭代器
整合 Druid 数据源
SQL监控和SQL防火墙无信息原因及解决方法
原因:
没有开启 Filter
( stat
、 wall
)配置。
以下开启方法将会开启失败:
datasource: ... # 配置监控统计拦截的filters,去掉后监控界面sql无法统计, #'wall'用于防火墙 filters: stat,wall
解决办法:
druid: filter: stat: enabled: true wall: enabled: true
开启后在数据源 filter
类名中可以查看到 stat
、 wall
的类名。(未开启之前是为空的)
具体配置如下:
spring: datasource: # driver-class-name: com.mysql.cj.jdbc.Driver # type: com.alibaba.druid.pool.DruidDataSource druid: url: jdbc:mysql://localhost:3306/tams_bg?serverTimezone=UTC username: root password: 123456 # 配置监控统计拦截的filters,去掉后监控界面sql无法统计, #'wall'用于防火墙 filter: stat: enabled: true wall: enabled: true # 配置StatFilter web-stat-filter: #默认为false,设置为true启动 enabled: true exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" #配置StatViewServlet stat-view-servlet: url-pattern: "/druid/*" #允许那些ip login-username: tom001 login-password: 1234 #禁止那些ip deny: 192.168.1.102 #是否可以重置 reset-enable: true #启用 enabled: true #最大等待时间,配置获取连接等待超时,时间单位都是毫秒ms max-wait: 60000 #最大值 max-active: 20 #最小值 min-idle: 5 #初始化大小 initial-size: 5 #配置一个连接在池中最小生存的时间 min-evictable-idle-time-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接 time-between-eviction-runs-millis: 300000 test-on-borrow: false test-on-return: false test-while-idle: true pool-prepared-statements: true #最大PSCache连接 max-pool-prepared-statement-per-connection-size: 20 use-global-data-source-stat: true # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 mybatis: type-aliases-package: com.justgo.tams_bg_pojo
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK