0%

2018年2月24日 下午3:29

数据库设计:

  1. 唯一索引
  2. 冗余:提高效率+功能要求
    1. 当前表的冗余 image
    2. 本来可以通过连接的表查找的内容user_id
  3. 相对地址:
  4. comment
  5. 无限分类
  6. dicimal(20,2)高精度类型
  7. 添加索引,提高索引效率
  8. btree
  9. 组合索引
  10. 后悔药

2018年2月23日 下午3:52

在第一次运行项目的时候提示找不到alipay的包文件:

Tomcat启动端口1099已被占用


解决:
Mac上解决java.rmi.server.ExportException- Port already in use- 1099; nested exception is- java.net.Bi - wojiushimogui的博客 - CSDN博客

  1. 第一步:使用lsof -i tcp:1099 查看时那个应用占用了此端口
  2. 第二部:使用kill pid 即可,这里的pid是第一步所查询到结果

2018年2月23日 下午3:23

有三个内容

  1. idea的注入和自动编译配置
  2. 项目初始化代码提交
  3. 两个提高工作效率的神器-Restlet Client和fe助手

idea的注入和自动编译配置

项目初始化代码提交

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
91
92
93
94
95
96
97
98
99
100
101
localhost:mmall czh$ git add .
localhost:mmall czh$ git status
On branch v1.0
Your branch is up-to-date with 'origin/v1.0'.

Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: pom.xml
new file: src/main/java/com/mmall/dao/CartMapper.java
new file: src/main/java/com/mmall/dao/CategoryMapper.java
new file: src/main/java/com/mmall/dao/OrderItemMapper.java
new file: src/main/java/com/mmall/dao/OrderMapper.java
new file: src/main/java/com/mmall/dao/PayInfoMapper.java
new file: src/main/java/com/mmall/dao/ProductMapper.java
new file: src/main/java/com/mmall/dao/ShippingMapper.java
new file: src/main/java/com/mmall/dao/UserMapper.java
new file: src/main/java/com/mmall/pojo/Cart.java
new file: src/main/java/com/mmall/pojo/Category.java
new file: src/main/java/com/mmall/pojo/Order.java
new file: src/main/java/com/mmall/pojo/OrderItem.java
new file: src/main/java/com/mmall/pojo/PayInfo.java
new file: src/main/java/com/mmall/pojo/Product.java
new file: src/main/java/com/mmall/pojo/Shipping.java
new file: src/main/java/com/mmall/pojo/User.java
new file: src/main/resources/applicationContext-datasource.xml
new file: src/main/resources/applicationContext.xml
new file: src/main/resources/datasource.properties
new file: src/main/resources/generatorConfig.xml
new file: src/main/resources/logback.xml
new file: src/main/resources/mappers/CartMapper.xml
new file: src/main/resources/mappers/CategoryMapper.xml
new file: src/main/resources/mappers/OrderItemMapper.xml
new file: src/main/resources/mappers/OrderMapper.xml
new file: src/main/resources/mappers/PayInfoMapper.xml
new file: src/main/resources/mappers/ProductMapper.xml
new file: src/main/resources/mappers/ShippingMapper.xml
new file: src/main/resources/mappers/UserMapper.xml
new file: src/main/resources/mmall.properties
new file: src/main/webapp/WEB-INF/dispatcher-servlet.xml
new file: src/main/webapp/WEB-INF/lib/alipay-sdk-java20161213173952-source.jar
new file: src/main/webapp/WEB-INF/lib/alipay-sdk-java20161213173952.jar
new file: src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215-source.jar
new file: src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215.jar
modified: src/main/webapp/WEB-INF/web.xml

localhost:mmall czh$ git commit -am "project init"
[v1.0 a5e501b] project init
37 files changed, 3051 insertions(+), 10 deletions(-)
create mode 100644 src/main/java/com/mmall/dao/CartMapper.java
create mode 100644 src/main/java/com/mmall/dao/CategoryMapper.java
create mode 100644 src/main/java/com/mmall/dao/OrderItemMapper.java
create mode 100644 src/main/java/com/mmall/dao/OrderMapper.java
create mode 100644 src/main/java/com/mmall/dao/PayInfoMapper.java
create mode 100644 src/main/java/com/mmall/dao/ProductMapper.java
create mode 100644 src/main/java/com/mmall/dao/ShippingMapper.java
create mode 100644 src/main/java/com/mmall/dao/UserMapper.java
create mode 100644 src/main/java/com/mmall/pojo/Cart.java
create mode 100644 src/main/java/com/mmall/pojo/Category.java
create mode 100644 src/main/java/com/mmall/pojo/Order.java
create mode 100644 src/main/java/com/mmall/pojo/OrderItem.java
create mode 100644 src/main/java/com/mmall/pojo/PayInfo.java
create mode 100644 src/main/java/com/mmall/pojo/Product.java
create mode 100644 src/main/java/com/mmall/pojo/Shipping.java
create mode 100644 src/main/java/com/mmall/pojo/User.java
create mode 100755 src/main/resources/applicationContext-datasource.xml
create mode 100755 src/main/resources/applicationContext.xml
create mode 100755 src/main/resources/datasource.properties
create mode 100755 src/main/resources/generatorConfig.xml
create mode 100755 src/main/resources/logback.xml
create mode 100644 src/main/resources/mappers/CartMapper.xml
create mode 100644 src/main/resources/mappers/CategoryMapper.xml
create mode 100644 src/main/resources/mappers/OrderItemMapper.xml
create mode 100644 src/main/resources/mappers/OrderMapper.xml
create mode 100644 src/main/resources/mappers/PayInfoMapper.xml
create mode 100644 src/main/resources/mappers/ProductMapper.xml
create mode 100644 src/main/resources/mappers/ShippingMapper.xml
create mode 100644 src/main/resources/mappers/UserMapper.xml
create mode 100755 src/main/resources/mmall.properties
create mode 100755 src/main/webapp/WEB-INF/dispatcher-servlet.xml
create mode 100755 src/main/webapp/WEB-INF/lib/alipay-sdk-java20161213173952-source.jar
create mode 100755 src/main/webapp/WEB-INF/lib/alipay-sdk-java20161213173952.jar
create mode 100755 src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215-source.jar
create mode 100755 src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215.jar
rewrite src/main/webapp/WEB-INF/web.xml (93%)
mode change 100644 => 100755
localhost:mmall czh$ git push
Counting objects: 51, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (48/48), done.
Writing objects: 100% (51/51), 3.18 MiB | 337.00 KiB/s, done.
Total 51 (delta 18), reused 0 (delta 0)
remote: Resolving deltas: 100% (18/18), done.
To github.com:czh55/imooc.git
ae65473..a5e501b v1.0 -> v1.0
localhost:mmall czh$ git status
On branch v1.0
Your branch is up-to-date with 'origin/v1.0'.

nothing to commit, working tree clean
localhost:mmall czh$

两个提高工作效率的神器-Restlet Client和fe助手

2018年2月22日 上午11:57

参考:
Mac环境变量(java)

下载jdk7
Java Archive Downloads - Java SE 7

切换JDK版本:
Mac jdk版本切换 | YNEIT.COM

1
2
3
4
5
6
7
8
9
10
11
12
localhost:~ czh$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
localhost:~ czh$ sudo open -e ~/.bash_profile
Password:
localhost:~ czh$ source ~/.bash_profile
localhost:~ czh$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
localhost:~ czh$

2018年2月22日 上午11:43

理解maven

介绍maven的作用、核心概念(Pom、Repositories、Artifact、Goal)、用法、常用参数和命令以及简单故障排除、扩展及配置

下载:

Mac下安装配置maven的问题小记 - yangbai - SegmentFault 思否

安装maven的位置:

更改环境变量.bash_profile:

1
2
3
4
5
6
7
8
9
10
localhost:~ czh$ sudo open -e .bash_profile
Password:
localhost:~ czh$ source ~/.bash_profile
localhost:~ czh$ mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800)
Maven home: /Library/apache-maven-3.0.5
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.3", arch: "x86_64", family: "mac"

2018年2月22日 上午11:08

idea中配置jdk:


idea配置maven路径:

创建项目:



排错:
maven “Generating project in Batch mode”问题的解决 - wardensky - 博客园
IDEA生成MAVEN项目报错_慕课猿问
java - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) - Stack Overflow

新建文件夹:注意mark成不同的颜色来区分功能

添加服务器:Run->Edit configurations





注:后来我又配置上了使用8088端口

启动运行时报错:
Apache Tomcat :java.net.ConnectException: Connection refused - Stack Overflow
出现 java.net.ConnectException: Connection refused 异常的原因及解决方法 - 维C果糖的博客 - CSDN博客

我的处理办法:关闭我手动打开的tomcat7

1
2
3
4
5
6
7
localhost:tomcat7 czh$ cd bin/
localhost:bin czh$ ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar

成功运行:

2018年2月22日 下午9:44

找到maven中pom的配置写法:
The Central Repository Search Engine

从分解 解耦的角度去理解就十分的简单

URI Is Not Registered - CSDN博客

剑客一:使用mybatis-generator:generate生成xml,dao,pojo

生成的xml,dao,pojo

数据库字段createtime,updatetime由mysql自动生成、更新

剑客二:试用期7天

剑客三:分页

GitHub - pagehelper/Mybatis-PageHelper: Mybatis通用分页插件
这里只是提一下,具体的使用在项目开发中说

Pom.xml中对应的配置:

2018年2月22日 下午8:35

git廖雪峰
注:在idea中的terminal窗口操作

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
localhost:mmall czh$ touch README.md
localhost:mmall czh$ touch .gitignore
localhost:mmall czh$ git init
Initialized empty Git repository in /Users/czh/IdeaProjects/mmall/.git/
localhost:mmall czh$ git status
On branch master

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)

.gitignore
README.md
pom.xml
src/

nothing added to commit but untracked files present (use "git add" to track)
localhost:mmall czh$ git add .
localhost:mmall czh$ git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)

new file: .gitignore
new file: README.md
new file: pom.xml
new file: src/main/webapp/WEB-INF/web.xml
new file: src/main/webapp/index.jsp

localhost:mmall czh$ git commit -am "first commit init project"

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'czh@localhost.(none)')
localhost:mmall czh$ git config --global user.email "you@example.com"
localhost:mmall czh$ git config --global user.email "czh55@qq.com"
localhost:mmall czh$ git commit -am "first commit init project"
[master (root-commit) ae65473] first commit init project
5 files changed, 79 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md
create mode 100644 pom.xml
create mode 100644 src/main/webapp/WEB-INF/web.xml
create mode 100644 src/main/webapp/index.jsp

添加远程源:

1
localhost:mmall czh$ git remote add origin git@github.com:czh55/imooc.git

查看当前本机分支:

1
2
localhost:mmall czh$ git branch
* master

提交远程分支报错:Permission denied (publickey)

1
2
3
4
5
6
7
8
9
10
11
localhost:mmall czh$ git push -u origin master
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
localhost:mmall czh$

设置本机Mac的秘钥和github上的秘钥

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
localhost:.ssh czh$ ssh-keygen -t rsa -C "czh55@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/czh/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/czh/.ssh/id_rsa.
Your public key has been saved in /Users/czh/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:n5Y9D5wI5LrU/+KgfHnmgRA6+PYAkLMHv/UoOKySSdk czh55@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| |
| . |
|= . . |
| * . . + |
|. B + . S |
|.= E + + + * . |
|++o = + +.B * |
|=. o = oo++. + |
|o =. =+o. . |
+----[SHA256]-----+
localhost:.ssh czh$ ssh-add ~/.ssh/id_rsa
Identity added: /Users/czh/.ssh/id_rsa (/Users/czh/.ssh/id_rsa)
localhost:.ssh czh$ ls
id_rsa id_rsa.pub known_hosts
localhost:.ssh czh$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfEDYzu0vTLrl2Pve+qJMVJSNffyV2f3suz2khr3X9uT+spxOg+P1TRaBQ3PFjINKfdSJcyCV05+1gv2aeNcLI3wDlui2Us3Rl5fXVRN/YsPOrR6m/RKqSmkpgTKeAE8+HoC3NQggEPZoytOM/L+M3no2PSqkeo/64tRTzWGigWEdGwWN3jeml28pQ+gonziD5OQRGHXlxPlWqDL51B0xhPap/jh8SVCP2mxTJBDuU2xUCoXC/ix87EomTp9bb24aikyyNh2yKtHhpvDK8TpN0gYXxah4yr2b30b8D1A/y2+YwcBPmfnlE+m49D/uzUfQQ9Z8ikgWMoqsXZnSrzlYN czh55@qq.com
localhost:.ssh czh$ git config --global gui.encoding utf-8
localhost:.ssh czh$ git config --global core.quotepath off
localhost:.ssh czh$ git config user.email
czh55@qq.com

再次push到远程:报错(e.g., ‘git pull …’) before pushing again.

1
2
3
4
5
6
7
8
9
localhost:mmall czh$ git push -u origin master
To github.com:czh55/imooc.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:czh55/imooc.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

拉取远程pull

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
localhost:mmall czh$ git pull
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:czh55/imooc
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> master

第三次push:报错because the tip of your current branch is behind

1
2
3
4
5
6
7
8
9
10

localhost:mmall czh$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts.
To github.com:czh55/imooc.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:czh55/imooc.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

强制覆盖提交到远程

1
2
3
4
5
6
7
8
9
10
localhost:mmall czh$ git push -u -f origin master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (11/11), 1.21 KiB | 414.00 KiB/s, done.
Total 11 (delta 0), reused 0 (delta 0)
To github.com:czh55/imooc.git
+ 3ce732e...ae65473 master -> master (forced update)
Branch master set up to track remote branch master from origin.
localhost:mmall czh$

提交成功

本地创建分支

1
2
3
4
5
6
localhost:mmall czh$ git checkout -b v1.0 origin/master
Branch v1.0 set up to track remote branch master from origin.
Switched to a new branch 'v1.0'
localhost:mmall czh$ git branch
master
* v1.0

并提交到远程

1
2
3
4
5
6
7
localhost:mmall czh$ git push origin HEAD -u
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
Total 0 (delta 0), reused 0 (delta 0)
To github.com:czh55/imooc.git
* [new branch] HEAD -> v1.0
Branch v1.0 set up to track remote branch v1.0 from origin.
localhost:mmall czh$

查看远程分支:

1
2
3
localhost:mmall czh$ git branch -r
origin/master
origin/v1.0

2018年2月22日 下午3:49

尝试过程

tomcat9配jdk7启动之后无法浏览器访问localhost:8080

1
2
3
4
5
6
7
localhost:bin czh$ ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat9
Using CATALINA_HOME: /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
Using CLASSPATH: /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Tomcat started.

现在切换jdk8

1
localhost:bin czh$ jdk8

tomcat9配jdk8可以正常访问localhost:8080

1
2
3
4
5
6
7
8
localhost:bin czh$ ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat9
Using CATALINA_HOME: /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Using CLASSPATH: /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Tomcat started.
localhost:bin czh$

进入tomcat7:

1
localhost:bin czh$ cd /usr/local/tomcat7/bin/

切换jdk7

1
localhost:bin czh$ jdk7

启动tomcat7:

1
2
3
4
5
6
7
8
9
10
11
localhost:bin czh$ sudo ./startup.sh
Password:
sudo: ./startup.sh: command not found
localhost:bin czh$ chmod u+x *.sh
localhost:bin czh$ ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.

结论:

  1. 我们在Mac的三个环境变量文件中都没有配置CATALINA_BASE:CATALINA_HOME,CATALINA_TMPDIR,这几个是根据tomcat的版本自动配置的
  2. 我们做的就是要根据要启动的tomcat版本,选择和式的jdk版本