标签:info ref conf har upd splay scope mac 数据库密码
一、.springboot的配置
1.安装并配置maven
maven是项目管理工具,可以自动下载并管理jar包之间的依赖关系,可通过maven自动配置springboot
参照百度经验https://jingyan.baidu.com/article/59703552cb9b988fc00740a4.html安装(eclipse下 )
2.新建maven项目,配置pom.xml文件(可直接使用)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>com.zty</groupId> 7 <artifactId>demo</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>jar</packaging> 10 11 <name>demo</name> 12 <description>Demo project for Spring Boot</description> 13 14 <parent> 15 <groupId>org.springframework.boot</groupId> 16 <artifactId>spring-boot-starter-parent</artifactId> 17 <version>2.0.1.RELEASE</version> 18 <relativePath/> <!-- lookup parent from repository --> 19 </parent> 20 21 <properties> 22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 23 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 24 <java.version>1.8</java.version> 25 </properties> 26 27 <dependencies> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter</artifactId> 31 </dependency> 32 <dependency> 33 <groupId>org.springframework.boot</groupId> 34 <artifactId>spring-boot-starter-test</artifactId> 35 <scope>test</scope> 36 </dependency> 37 <dependency> 38 <groupId>org.springframework.boot</groupId> 39 <artifactId>spring-boot-starter-web</artifactId> 40 </dependency> 41 <dependency> 42 <groupId>org.springframework.boot</groupId> 43 <artifactId>spring-boot-starter-freemarker</artifactId> 44 </dependency> 45 <dependency> 46 <groupId>org.springframework.boot</groupId> 47 <artifactId>spring-boot-starter-jdbc</artifactId> 48 </dependency> 49 <dependency> 50 <groupId>org.mybatis.spring.boot</groupId> 51 <artifactId>mybatis-spring-boot-starter</artifactId> 52 <version>1.1.1</version> 53 </dependency> 54 55 <dependency> 56 <groupId>mysql</groupId> 57 <artifactId>mysql-connector-java</artifactId> 58 <scope>runtime</scope> 59 </dependency> 60 <dependency 61 > <groupId>com.alibaba</groupId> 62 <artifactId>druid</artifactId> 63 <version>1.0.29</version> 64 </dependency> 65 66 <dependency> 67 <groupId>org.springframework.boot</groupId> 68 <artifactId>spring-boot-devtools</artifactId> 69 <optional>true</optional> 70 </dependency> 71 <dependency> 72 <groupId>org.springframework.boot</groupId> 73 <artifactId>spring-boot-starter-tomcat</artifactId> 74 <scope>provided</scope> 75 </dependency> 76 <!-- bootstrap和jquery --> 77 <dependency> 78 <groupId>org.webjars</groupId> 79 <artifactId>bootstrap</artifactId> 80 <version>3.3.5</version> 81 </dependency> 82 <dependency> 83 <groupId>org.webjars</groupId> 84 <artifactId>jquery</artifactId> 85 <version>3.1.1</version> 86 </dependency> 87 88 </dependencies> 89 90 <build> 91 <plugins> 92 <plugin> 93 <groupId>org.springframework.boot</groupId> 94 <artifactId>spring-boot-maven-plugin</artifactId> 95 <configuration> 96 <fork>true</fork> 97 </configuration> 98 </plugin> 99 </plugins> 100 </build> 101 102 </project>
这里分别配置了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目录下)
1 spring.datasource.url=#这里是数据库连接url spring.datasource.username=#这里是数据库用户名 spring.datasource.password=#这里是数据库密码 spring.datasource.driver-class-name=#这里是数据库驱动
修改服务器端口
1 server.port=80
配置freemarker
1 spring.freemarker.allow-request-override=false 2 spring.freemarker.cache=true 3 spring.freemarker.check-template-location=true 4 spring.freemarker.charset=UTF-8 5 spring.freemarker.content-type=text/html 6 spring.freemarker.expose-request-attributes=false 7 spring.freemarker.expose-session-attributes=false 8 spring.freemarker.expose-spring-macro-helpers=false 9 spring.freemarker.suffix=.ftl 10 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)
标签:info ref conf har upd splay scope mac 数据库密码
原文地址:https://www.cnblogs.com/ztybug/p/8970757.html