springboot搭建环境整合jsp页面整合mybatis
1.pom文件依赖
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hive</groupId>
<artifactId>myspringboot</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>myspringboot Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- web支持: 1、web mvc; 2、restful; 3、jackjson支持; 4、aop ........ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- servlet 依赖. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- 添加fastjson 依赖包. -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<!-- tomcat 的支持.-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- mysql 数据库驱动. -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--
spring-boot mybatis依赖:
请不要使用1.0.0版本,因为还不支持拦截器插件,
1.1.1 是博主写帖子时候的版本,大家使用最新版本即可
-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- datasource heroku -->
<!-- <dependency> -->
<!-- <groupId>com.zaxxer</groupId> -->
<!-- <artifactId>HikariCP-java6</artifactId> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <artifactId>tools</artifactId> -->
<!-- <groupId>com.sun</groupId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- aspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.hateoas</groupId> -->
<!-- <artifactId>spring-hateoas</artifactId> -->
<!-- </dependency> -->
<!-- javax -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<!--
MyBatis提供了拦截器接口,我们可以实现自己的拦截器,
将其作为一个plugin装入到SqlSessionFactory中。
Github上有位开发者写了一个分页插件,我觉得使用起来还可以,挺方便的。
Github项目地址: https://github.com/pagehelper/Mybatis-PageHelper
-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.0</version>
</dependency>
<!-- 添加MySQL数据库驱动依赖包. -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<!-- 添加Spring-data-jpa依赖. -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId> -->
<!-- </dependency> -->
<!-- spring boot devtools 依赖包. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork : 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
<!-- <finalName>myspringboot</finalName> -->
</project>
2.application.yml
server:
port: 8001
spring:
application:
name: myspringboot
datasource:
url: jdbc:mysql://192.168.103.169:3306/dmcdb?useUnicode=true&characterEncoding=utf-8
username: root
password: 123
driverClassName: com.mysql.jdbc.Driver
mybatis:
mapperLocations: classpath:mybatis/mapper/*.xml
typeAliasesPackage: com.hive.entity
configLocation: classpath:mybatis/mybatis-config.xml
3.application.properties
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
4.注意静态资源js默认放入这个static路径下
5.Aplication.java代码:
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(basePackages ={"com.hive.*"})
@EnableAutoConfiguration
@SpringBootApplication
public class Aplication {
public static void main(String[] args) {
SpringApplication.run(Aplication.class, args);
}
}
6.Mapper代码:
package com.hive.mapper;
import com.hive.entity.DevUser;
import com.hive.entity.DevUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DevUserMapper {
int countByExample(DevUserExample example);
int deleteByExample(DevUserExample example);
int deleteByPrimaryKey(Long id);
int insert(DevUser record);
int insertSelective(DevUser record);
List<DevUser> selectByExample(DevUserExample example);
DevUser selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") DevUser record, @Param("example") DevUserExample example);
int updateByExample(@Param("record") DevUser record, @Param("example") DevUserExample example);
int updateByPrimaryKeySelective(DevUser record);
int updateByPrimaryKey(DevUser record);
}
springboot搭建环境整合jsp页面整合mybatis的更多相关文章
- Spring Boot Web项目整合jsp页面访问
这个内容就是实操过程中各种访问不了jsp页面,各种尝试后的解决方案吧.可能不是最优的,但是目前能解决项目中的一些问题.之前觉得没有什么问题直接可以操作的,没想到在这部分还是耗时了. 开发工具idea2 ...
- SpringBoot项目中加入jsp页面
根据我们之前搭建好的SpringBoot+SSm的项目的基础上,来增加webapp/WEB-INF的文件,由此来完成jsp页面的跳转. 先增加jsp的pom依赖: <!-- https://mv ...
- 07.整合jsp、整合freemarker、整合thymeleaf
整合jsp pom.xml部分内容 <packaging>war</packaging> </dependencies> <dependency> &l ...
- springboot项目WEB-INF 目录 jsp页面报404
我是跟着<深入浅出 Spring Boot 2.x>这本书学习的,在"初识Spring MVC"章节中,搭建项目,然后访问jsp页面时报错:Path with &quo ...
- SpringBoot搭建环境
选择文件新建一个项目 选择:Spring Initializr,其他配置不变,点击下一步 这里一般写包名和项目名,这里我就默认,直接点击下一步 这里选择:Web --> Spring Web ...
- springboot搭建环境访问Controller层返回404
如果启动成功,但是却访问不了你自己写的controller,报404错误,那么原因就是您写的controller没有被spring 容器扫描到 解决方案: spring boot 默认扫描您的类是 在 ...
- springboot搭建环境之使用@Slf4j注解方式,进行日志管理
如果不想每次都写private final Logger logger = LoggerFactory.getLogger(XXX.class); 可以用注解@Slf4j 需要引入依赖为: < ...
- JAVA SpringBoot2 整合 JSP视图模板 整合 Ueditor富文本编辑器
一般涉及到后台管理系统,就少不了富文本编辑器,这个可以图,文,视频混排的高级工具,笔者通过对比,发现目前市场上最好的三方库还当属百度的 ueditor 近年来 SpringBoot 框架可谓越来越火, ...
- 使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境
做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框 ...
随机推荐
- io 流概念
io 流概念 对输入输出抽象的封装
- ftp下载文件失败get: Access failed: 550 Failed to open file. (t1.log)
get: Access failed: 550 Failed to open file. (t1.log) 原因是被SELinux安全访问控制策略限制了. 科普: SELinux(Security-E ...
- 【转】阿里出品的ETL工具dataX初体验
原文链接:https://www.imooc.com/article/15640 来源:慕课网 我的毕设选择了大数据方向的题目.大数据的第一步就是要拿到足够的数据源.现实情况中我们需要的数据源分布在不 ...
- [转载]oracle 数据类型详解---日期型
1.常用日期型数据类型1.1.DATE这是ORACLE最常用的日期类型,它可以保存日期和时间,常用日期处理都可以采用这种类型.DATE表示的日期范围可以是公元前4712年1月1日至公元9999年12月 ...
- [转载]图解程序员必须掌握的Java常用8大排序算法
这篇文章主要介绍了Java如何实现八个常用的排序算法:插入排序.冒泡排序.选择排序.希尔排序 .快速排序.归并排序.堆排序和LST基数排序,分享给大家一起学习. 分类1)插入排序(直接插入排序.希尔排 ...
- Hadoop学习笔记之二:NameNode
NameNode对三大协议接口(NamenodeProtocol.ClientProtoco.DatanodeProtocol)进行实现,利用ipc::Server通过三个协议分别向SNN.Clien ...
- css实现16:9的图片比例
摘自:https://www.cnblogs.com/caizhenbo/p/css.html 需求: 最近产品要求不管原图的大小是多少,宽度一定,高度要自自适应为16:9. 分析: 对于正常的固定好 ...
- imageio.ffmpeg.download() has been deprecated. Use 'pip install im ageio-ffmpeg' instead.'
Use this instead: sudo pip3 install imageio==2.4.1
- VIM编码检查
trouble shooting https://www.django.cn/article/show-4.html https://blog.csdn.net/lh756437907/article ...
- Net中应用 Redis 扩展类
GIt地址:https://gitee.com/loogn/stackexchange-redis-typedextensions 1.stackexchange 类调用 using System; ...