文件 - >新建 - >项目
选择Spring Initializr点击下一步,再点击下一个
然后再这个页面下
选择Web下的Web然后点击下一个即可,这样就搭建好最简单的springMVC框架了
如果在这一步还勾选了SQL下的MySQL和Mybatis,则需要配置MySQL和Mybatis
(模板引擎下的Thymeleaf(HTML5)和Freemarker(jsp))
如何配置MySQL和Mybatis:
server.port=8081
#jdbc-druid
spring.datasource.name=test
spring.datasource.url=jdbc:mysql://192.168.9.188:3306/login?useUnicode=true&characterEncoding=UTF8&useSSL=false&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root
spring.datasource.password= 123456
#mybatis
mybatis.mapper-locations=classpath:/mapper/**/*.xml
mybatis.typeAliasesPackage= com.example.demo
# ???druid?????
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.filters=stat
spring.datasource.maxActive=20
spring.datasource.initialSize=1
spring.datasource.maxWait=60000
spring.datasource.minIdle=1
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=20
spring.freemarker.prefix=classpath*:/templates/
spring.freemarker.suffix=.html
spring.freemarker.allow-request-override=false
spring.freemarker.allow-session-override=false
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.prefer-file-system-access=true
spring.freemarker.template-loader-path=classpath*:/templates/
以上为参考,还要导入Maven :File–>setting下搜索Maven,然后在Maven home director下选择下载的Maven,导入,然后点击OK。完成。