转 载:https://blog.csdn.net/weixin_42545531/article/details/82414810
https://gitee.com/xiaoZhengJC/springboot-ssm-test
也算是给自己留给底便于以后忘记了可以在回来看看
模块分为:common、service、dao、web
web项目默认的parent是
org.springframework.boot
spring-boot-starter-parent
2.0.4.RELEASE
如果需要换成自己的parent(从其其他子级项目中粘贴即可)
1、首先创建一个父级项目(new-file-project)
5、之后就是 common dao service web 等的创建 前三者选择Maven jar形式 而web 则需要Spring Initializr
注意:选择 Maven 点击next 注意Create from achetype 是没有勾选的
6、注意 Module name:框 需要于之前的Artifactld 保持一致 应为idea默认是驼峰式命名的 点击finish
7、这里特殊介绍下怎么去除与父工成的关联 在你选择的项目上右键找到Remove Model 点击
8、现在来介绍下子级web工程,(父级节点右键-New-file-module-spring Initalizr)
package 写入com.czxy 点击next
注意:版本选择与父级工程一致
9、在父项目的pom 中你会发现 其实 springboot-web 没有与父工程关联
10、所以我们进行如下步骤:
11、从其他项目的pom下复制 到 springboot-web 下的pom
12、之后我们在修改父项目下的pom 引入springboot-web module
13、接下就在ssm父级项目下的pom.xml导入相应的启动器
UTF-8
UTF-8
1.8
1.3.2
2.0.2
5.1.32
1.2.5
1.1.10
org.projectlombok
lombok
1.16.10
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-jdbc
org.mybatis.spring.boot
mybatis-spring-boot-starter
${mybatis.starter.version}
tk.mybatis
mapper-spring-boot-starter
${mapper.starter.version}
com.github.pagehelper
pagehelper-spring-boot-starter
${pageHelper.starter.version}
mysql
mysql-connector-java
${mysql.driver}
com.alibaba
druid-spring-boot-starter
${durid.starter.version}
org.springframework.boot
spring-boot-starter-test
test
14、如果一个模块需要引入另一个模块的东西就在需要引入模块的pom文件配置
例:controller引入service模块
com.csxm
springboot-service
0.0.1-SNAPSHOT
compile
15、运行前我们在springboot-web项目下的 application.properties 下配置 端口映射 数据库连接 druid连接池
#Tomcat
server.port=8080
#DB configuration
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/project_bak20191209?useUnicode=true&&useSSL=false&&characterEncoding=UTF-8&&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
#druid
#驱动
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#初始化连接池大小
spring.datasource.druid.initial-size=1
#最小连接数
spring.datasource.druid.min-idle=1
#最大连接数
spring.datasource.druid.max-active=20
#获取连接时候验证,会影响性能
# spring.datasource.druid.test-on-borrow=true
# mybatis
# mybatis.type-aliases-package=com.czxy.domain.base
# mybatis.mapper-locations=classpath:mappers/*.xml
#mapper
# mapper.not-empty=false
# mapper.identity=MYSQL
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true
# httpclient
# http.maxTotal=300
# http.defaultMaxPerRoute=50
# http.connectTimeout=1000
# http.connectionRequestTimeout=500
# http.socketTimeout=5000
# http.staleConnectionCheckEnabled=true
16、在web-resources创建一个static放我们的html界面,以后的js,cs也放这里面
17、项目pom.xml依赖关系(web->controller->service->dao)
18、启动器配置