1.創(chuàng)建工程
①坐標(biāo)
group id:com.rgh.crowd
artifact id:distribution-crowd-7-webui
[注:仍然是父工程的模塊工程形式]
②依賴
<!-- 加入Web開發(fā)所需要的場(chǎng)景啟動(dòng)器 -->
<dependency>
<!-- 指定groupId和artifactId即可姨伤,版本已在父工程中定義 -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 引入springboot&redis整合場(chǎng)景 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- 引入springboot&springsession整合場(chǎng)景 -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!-- Thymeleaf依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.rgh.crowd</groupId>
<artifactId>distribution-crowd-1-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
③主啟動(dòng)類
@EnableFeignClients
@EnableEurekaClient
@SpringBootApplication
public class CrowdMainType {
public static void main(String[] args) {
SpringApplication.run(CrowdMainType.class, args);
}
}
④配置文件
server:
port: 80
spring:
application:
name: webui
redis:
host: 192.168.56.150
jedis:
pool:
max-idle: 100
session:
store-type: redis
thymeleaf:
prefix: classpath:/templates/
suffix: .html
cache: false
eureka:
client:
register-with-eureka: false
service-url:
defaultZone: http://localhost:1000/eureka/
instance:
prefer-ip-address: true
2.顯示首頁(yè)
①加入index.html
②加入靜態(tài)資源
③修改index.html
字符集和Thymeleaf名稱空間的聲明
<html lang="UTF-8" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
靜態(tài)資源訪問(wèn)路徑(下面僅列出有代表性的)
<link rel="stylesheet" th:href="@{/resources/bootstrap/css/bootstrap.min.css}" href="bootstrap/css/bootstrap.min.css">
<img th:src="@{/resources/img/carousel-1.jpg}" src="img/carousel-1.jpg" alt="First slide">
<script th:src="@{/resources/script/docs.min.js}" src="script/docs.min.js"></script>