1、.springboot的配置css
1.安裝並配置mavenhtml
maven是項目管理工具,能夠自動下載並管理jar包之間的依賴關係,可經過maven自動配置springboot前端
參照百度經驗https://jingyan.baidu.com/article/59703552cb9b988fc00740a4.html安裝(eclipse下 )java
2.新建maven項目,配置pom.xml文件(可直接使用) mysql
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環境搭建完成jquery
3.配置springboot+mybatis+freemarkerweb
找到application.properties配置文件(通常在/src/main/resources目錄下)spring
1 spring.datasource.url=#這裏是數據庫鏈接url spring.datasource.username=#這裏是數據庫用戶名 spring.datasource.password=#這裏是數據庫密碼 spring.datasource.driver-class-name=#這裏是數據庫驅動
修改服務器端口sql
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