springboot+mybatis+集成jsp
springboot+mybatis
由于springboot不推荐使用jsp,所以针对集成jsp搭建过程出现的一系列问题做一个简单记录。
一、项目创建
1.新建项目。
2.编辑组名、项目名、项目类型为maven项目、打包根据实际情况选择打jar包还是打war包、jdk版本。然后下一步。
3.选择依赖,因为我这里用的是达梦数据库,选项里没有,可以通过pom文件引入驱动jar包。
4.完成项目创建。
二、添加webapp
1.删除没有用的文件。
2.兼容jsp,完成后目录结构。
三、配置文件
1.application.properties
spring.profiles.active=dev
#spring.mvc.view.prefix=/WEB-INF/
#spring.mvc.view.suffix=.jsp
#编辑jsp时自动更新,编辑java时不会自动更新需要重启服务器
server.servlet.jsp.init-parameters.development=true
2.application.yml
server:
port: 8080 #访问端口
servlet:
context-path: /ied #访问路径
spring:
mvc:
view:
prefix: /ui/ #视图解析默认路径
suffix: .jsp
application:
name: ied
datasource:
# url: jdbc:dm://xx.xx.xx.xx:5236
url: jdbc:dm://xx.xx.xx.xx:5236
# url: jdbc:dm://xx.xx.xx.xx:5236
username: SYSDBA
password: SYSDBA
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: dm.jdbc.driver.DmDriver
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
# profiles:
# active: spring #spring为application-spring.yml文件名的添加部分(加载外部yml文件)
mybatis:
mapper-locations: classpath:mapper/*.xml #classpath就是应用程序resources的路径
type-aliases-package: com.search.elastic.model
3.pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ytu