JavaEE课程踩坑记录

踩坑记录

1. 数据库时区有关异常

  • 解决方案:添加时区参数jdbc:mysql://localhost:3306/DATABASE?serverTimezone=UTC

2. 更换Maven源

  • 解决方案:在setting.xml中加入国内源
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
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->

<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

<mirror>
<id>uk</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>

<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>

</mirrors>
</settings>

3. AOP后置通知和最终通知的顺序颠倒

  • 解决方案:将spring-context版本设为5.2.7.RELEASE

4. 有关MyBatis

Mybatis中的mapper中的xml文件中写SQL语句时,小于号以及大于号要写成&lt;以及&gt;否则会与xml中的尖括号冲突。

5. 有关微信小程序

在微信小程序中,要求使用https协议。在这里采取的方法是将后台应用部署到服务器上,并使用nginx进行反向代理。最后申请域名,上https证书。

nginx的配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
listen 443 ssl; #配置HTTPS的默认访问端口号为443。此处如果未配置HTTPS的默认访问端口,可能会造成Nginx无法启动。Nginx 1.15.0以上版本请使用listen 443 ssl代替listen 443和ssl on。
server_name wwww.kuumtde.cn; #将www.certificatestests.com修改为您证书绑定的域名,例如:www.example.com。如果您购买的是通配符域名证书,要修改为通配符域名,例如:*.aliyun.com。
root html;
index index.html index.htm;
ssl_certificate cert/4683033_kuumtde.cn.pem; #将domain name.pem替换成您证书的文件名称。
ssl_certificate_key cert/4683033_kuumtde.cn.key; #将domain name.key替换成您证书的密钥文件名称。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;

location / {
root html; #站点目录。
index index.html index.htm;
proxy_pass http://127.0.0.1:8080;
}
}

配置完成后,重启nginx即可

1
2
3
cd /usr/local/nginx/sbin
./nginx -s stop
./nginx

或者重新加载配置文件也可:

1
./nginx -s reload

6. 服务端上项目的打包以及部署

首先进入项目目录,然后编译、打包、运行

1
2
3
4
mvn clean
mvn compile
mvn package
nohup java -jar XXX.jar