记springboot+mybatis+freemarker+bootstrap的使用(1)
一、.springboot的配置
1.安装并配置maven
maven是项目管理工具,可以自动下载并管理jar包之间的依赖关系,可通过maven自动配置springboot
参照百度经验https://jingyan.baidu.com/article/59703552cb9b988fc00740a4.html安装(eclipse下 )
2.新建maven项目,配置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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.zty</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>demo</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency> <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency
> <groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.29</version>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- bootstrap和jquery -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1</version>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build> </project>
pom.xml
这里分别配置了springboot核心jar包,springboot-web核心jar包,tomcat的jar包,jdbc的jar包,mybatis的jar包,freemarker的jar包,mysql驱动的jar包,spring-boot开发环境的jar包,bootstrap和jquery的jar包,在这里我用的是mybatis,所以jdbc的jra包依赖可以删除。配置完保存之后,右键项目目录->maven->update project,springboot环境搭建完成
3.配置springboot+mybatis+freemarker
找到application.properties配置文件(一般在/src/main/resources目录下)
spring.datasource.url=#这里是数据库连接url spring.datasource.username=#这里是数据库用户名 spring.datasource.password=#这里是数据库密码 spring.datasource.driver-class-name=#这里是数据库驱动
修改服务器端口
server.port=80
配置freemarker
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
至此基本的配置已经结束,如果想使用前端框架bootstrap需要在src/main/resources/static下新建一个空的目录命名为webjars,在前端页面插入
<script src="webjars/jquery/3.1.1/jquery.min.js"></script>
<script src="webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="webjars/bootstrap/3.3.5/css/bootstrap.min.css" />
就可以使用bootstrap和jquery了。
来自本萌新的笔记,如果有误望各位大佬指正 :-p

记springboot+mybatis+freemarker+bootstrap的使用(1)的更多相关文章
- 记springboot+mybatis+freemarker+bootstrap的使用(2)
二.springboot+mybatis的使用 1.springboot的注解:@SpringBootApplication :启动项目:整合常用注解(@Configuration,@EnableAu ...
- 在MyEclipse中搭建spring-boot+mybatis+freemarker框架
一.创建项目 1.右键-->New-->Project... 2.选中Maven Project,点击next 3.选中第一个 4.添写Group Id,Artifact Id,选择Com ...
- 在MyEclipse中使用spring-boot+mybatis+freemarker实现基本的增删改查
一.基本环境 二.创建实体类 1.User.java package bjredcross.rainbowplans.model; import bjredcross.rainbowplans.com ...
- SpringBoot+Mybatis+Freemark 最简单的例子
springboot-sample 实现最简单的 SpringBoot + Mybatis + Freemarker 网页增删改查功能,适合新接触 Java 和 SpringBoot 的同学参考 代码 ...
- springboot+mybatis+bootstrap开发员工oa后台管理系统项目源码
java项目源码详情描述:S020<springboot+mybatis+bootstrap开发员工oa后台管理系统项目源码>jboa项目有请假以及报销单的申请和审核session共享加登 ...
- 记一次springboot+mybatis+phoenix在代码集成中的坑
场景: 希望使用phoenix做查询服务,给服务端提供接口 设计: 通过springboot做restful的接口发布,通过mybatis做phoenix的sql处理,因此是springboot+my ...
- Springboot+Mybatis+MySQL实例练习时踩坑记录
最近刚开始学习后端,直接让上手学习Springboot+Mybatis+MySQL对CRUD的实例,虽然实例不难,但是上面的三个知识我都不懂,就有点为难我了 所以经常遇到一个点卡自己很久的情况,这里列 ...
- SpringBoot第十一篇:SpringBoot+MyBatis+Thymelaf实现CRUD
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10936304.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言 总结前面几 ...
- springboot+mybatis+druid+atomikos框架搭建及测试
前言 因为最近公司项目升级,需要将外网数据库的信息导入到内网数据库内.于是找了一些springboot多数据源的文章来看,同时也亲自动手实践.可是过程中也踩了不少的坑,主要原因是我看的文章大部分都是s ...
随机推荐
- Linux文件系统检查错误
我们的Linux系统在无法启动时候,通常需要进入单用户模式下进行修改一些配置文件,或调整一些参数方可.但是在进入单用户模式后,我们的/文件系统是只读模式,无法进行修改,那么这个时候我们就需要用到一条命 ...
- JQuery里ajax的表单传值serialize()用法
本文导读:在jQuery中,当我们使用ajax时,常常需要拼装 input数据以键值对(Key/Value)的形式发送到服务器,用JQuery的serialize方法可以轻松的完成这个工作 ...
- February 2 2017 Week 5 Thursday
Only do what your heart tells you. 随心而行. My heart tells me that I should leave here and go back to X ...
- 【2D游戏引擎】WIP反思
WIP(Working In Progress)是我初学游戏引擎开发时候开发的一个2D游戏引擎,当时计划为它实现类似Unity一样的编辑器,具有和Unity相似的工作流,但是由于水平不够,走了很多弯路 ...
- mysqlslap执行基准测试
查看mysqlslap所支持的主要参数配置及说明如下 -a, --auto-generate-sql 由系统自动生成SQL脚本进行测试 Generate SQL where not supplied ...
- UVa 1638 - Pole Arrangement(dp)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- tensorflow训练代码
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf mnist = input_dat ...
- 利用来JS控制页面控件显示和隐藏有两种方法
利用来JS控制页面控件显示和隐藏有两种方法,两种方法分别利用HTML的style中的两个属性,两种方法的不同之处在于控件隐藏后是否还在页面上占空位. 方法一: 1 2 document.getEle ...
- STC12LE5620AD RAM问题
1.此款单片机内部有 sram:768B=512B(aux)+256B(Internal) 2.内部RAM解析 2. 3.内部扩展RAM 4.keil中可以选择内存类型 5. 网上摘抄的一段话: 在S ...
- if else 和 switch的效率
switch在判断分支时,没有判断所有的可能性,而是用一个静态表来解决这个问题,所以速度要比if-else快. 但是,switch对较复杂的表达式进行判断,所以当我们需要判断一些简单数值时,用swit ...