尚筹网2-5.前端工程(2).创建前端工程

1.创建工程

①坐标

group id:com.rgh.crowd

artifact id:distribution-crowd-7-webui

[注:仍然是父工程的模块工程形式]

②依赖

<!-- 加入Web开发所需要的场景启动器 -->
<dependency>
    <!-- 指定groupId和artifactId即可,版本已在父工程中定义 -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 引入springboot&redis整合场景 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- 引入springboot&springsession整合场景 -->
<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>

③主启动类

@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.显示首页

①加入index.html

②加入静态资源

③修改index.html

字符集和Thymeleaf名称空间的声明

<html lang="UTF-8" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8">

静态资源访问路径(下面仅列出有代表性的)

<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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容