idea中部署maven下ssm框架

Intellij IDEA2017 创建maven项目

关于基础环境配置这里不做说明,只在idea上新建建maven项目。
本文章仅为学习过程中的记录笔记。
一、新建maven项目
1.1、首先打开idae,点击File–>New–>Project

这里写图片描述
1.2、选择创建maven项目,选好jdk版本,选择webapp模型,然后点Next

这里写图片描述
1.3、设置好包名和项目名

这里写图片描述
1.4、选择好自己配置的maven环境

这里写图片描述

这里写图片描述
1.5、选择Enable Auto-Import生成maven项目

这里写图片描述
1.6、生成完成后项目的目录结构

这里写图片描述
二、配置文件

这是接下来需要添加的目录和文件结构,如图:
这里写图片描述
pom.xml配置
01、先在上面设置好一些包版本号,方便以后修改版本号。



4.0.2.RELEASE

3.2.6

1.7.7
1.2.17

1
2
3
4
5
6
7
8
9
10
11

02、然后再添加一下依赖包到


junit
junit
4.11

test



org.springframework
spring-core
${spring.version}


org.springframework
spring-web
{spring.version}


org.springframework
spring-tx
${spring.version}


org.springframework
spring-jdbc
${spring.version}


org.springframework
spring-webmvc
{spring.version}


org.springframework
spring-context-support
${spring.version}


org.springframework
spring-test
{mybatis.version}



org.mybatis
mybatis-spring
1.2.2



javax
javaee-api
7.0



mysql
mysql-connector-java
5.1.30



commons-dbcp
commons-dbcp
1.2.2



jstl
jstl
1.2




log4j
log4j
${log4j.version}

  
  
      com.alibaba
      druid
      1.0.12
  

  
      com.fasterxml.jackson.core
      jackson-core
      2.8.5
  

  
      com.fasterxml.jackson.jaxrs
      jackson-jaxrs-xml-provider
      2.4.1
  
  
      org.codehaus.jackson
      jackson-mapper-asl
      1.9.4
  
  
  com.fasterxml.jackson.core
  jackson-databind
  2.8.5



com.fasterxml.jackson.core
jackson-annotations
2.8.5


com.alibaba
fastjson
1.2.3


org.slf4j
slf4j-log4j12
${slf4j.version}



commons-fileupload
commons-fileupload
1.3.1


commons-io
commons-io
2.4


commons-codec
commons-codec
1.9



com.github.pagehelper
pagehelper
4.0.0



  com.github.pagehelper
  pagehelper
  4.0.0


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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

03、在中添加mybatis-generator插件,主要用于mybatis自动生成dao,model,mapping。



org.mybatis.generator
mybatis-generator-maven-plugin
1.3.2

true
true


1
2
3
4
5
6
7
8
9
10
11
12
13

2.1、在resources里创建数据库配置文件:jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/vip
jdbc.username=root
jdbc.password=123456

定义初始连接数

initialSize=0

定义最大连接数

maxActive=20

定义最大空闲

maxIdle=20

定义最小空闲

minIdle=1

定义最长等待时间

maxWait=60000

1
2
3
4
5
6
7
8
9
10
11
12
13
14

2.2、在resources里创建日志文件:log4j.properties

log4j.rootLogger=INFO,Console,File

定义日志输出目的地为控制台

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out

可以灵活地指定日志输出格式,下面一行是指定具体的格式

log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n

文件大小到达指定尺寸的时候产生一个新的文件

log4j.appender.File = org.apache.log4j.RollingFileAppender

指定输出目录

log4j.appender.File.File = logs/ssm.log

定义文件最大大小

log4j.appender.File.MaxFileSize = 10MB

输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志

log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH:mm:ss}][%c]%m%n

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

2.3、在resources里创建spring-mvc.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">








    
        
            text/plain;charset=UTF-8
        
    





    
        
            
            
        
    




    
    
    




    
    
    
    
    
    











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

2.4、在resources里创建spring-mybatis.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">



class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


    
    
    
    
    
    
    
    
    
    
    
    
    
    




    
    
    




    
    




    

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

2.5、在resources里创建mybatis自动生成代码配置文件:generatorConfig.xml
mapping文件生成在了resources文件夹里,idea里跟eclipse不同,如果生成的xml文件不在resources里,项目跑起来会提示找不到XXXmapping.xml文件


"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >





    
        
        
    

    
    

    
        
    

    
    
    
        
        
    

    
    
    
        
    

    
    
    
        
    

    
    
    

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

2.6、配置web.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

Archetype Created Web Application


contextConfigLocation
classpath:spring-mybatis.xml




encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
true

encoding
UTF-8



encodingFilter
/*




org.springframework.web.context.ContextLoaderListener



org.springframework.web.util.IntrospectorCleanupListener



SpringMVC
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:spring-mvc.xml

1
true


SpringMVC
/


/index.jsp

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

三、用mybatis-generator插件生成代码
3.1、首先配置启动,点击idea右上角的启动方式

这里写图片描述

这里写图片描述
3.2、在comman line 那栏配置mybatis-generator:generate -e

这里写图片描述
启动之前需要建立java主文件夹,存放java代码

这里写图片描述

。。。。。。。。。

这里写图片描述

。。。。

这里写图片描述
3.3、启动刚刚配置maven插件

这里写图片描述
==执行完后结果图:

这里写图片描述
四、配置tomcat
这里写图片描述

。。。。。。。。。。
这里写图片描述

。。。
这里写图片描述

这里写图片描述

这里写图片描述

本文章仅为学习过程中的记录笔记

作者:Vicent-jie
来源:CSDN
原文:https://blog.csdn.net/qq_25591191/article/details/78745312
版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(idea中部署maven下ssm框架)