Thymeleaf Petclinic 项目教程

Thymeleaf Petclinic 项目教程

thymeleafexamples-petclinicSpring PetClinic + Thymeleaf- Companion application for the "Bringing Thymeleaf and Natural Templates to the Spring PetClinic" article at the Thymeleaf website: http://www.thymeleaf.org/doc/articles/petclinic.html项目地址:https://gitcode.com/gh_mirrors/th/thymeleafexamples-petclinic

1. 项目的目录结构及介绍

Thymeleaf Petclinic 项目的目录结构如下:

thymeleafexamples-petclinic/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── org/
│   │   │       └── thymeleaf/
│   │   │           └── examples/
│   │   │               └── petclinic/
│   │   │                   ├── Application.java
│   │   │                   ├── config/
│   │   │                   ├── controller/
│   │   │                   ├── model/
│   │   │                   ├── repository/
│   │   │                   └── service/
│   │   ├── resources/
│   │   │   ├── application.properties
│   │   │   ├── log4j.properties
│   │   │   └── messages/
│   │   └── webapp/
│   │       ├── WEB-INF/
│   │       │   └── views/
│   │       └── resources/
│   └── test/
│       └── java/
│           └── org/
│               └── thymeleaf/
│                   └── examples/
│                       └── petclinic/
└── pom.xml

目录结构介绍

  • src/main/java/:包含项目的所有 Java 源代码。
    • org/thymeleaf/examples/petclinic/:项目的主要包。
      • Application.java:项目的启动类。
      • config/:包含项目的配置类。
      • controller/:包含项目的控制器类。
      • model/:包含项目的模型类。
      • repository/:包含项目的仓库类。
      • service/:包含项目的服务类。
  • src/main/resources/:包含项目的资源文件。
    • application.properties:项目的配置文件。
    • log4j.properties:日志配置文件。
    • messages/:包含国际化消息文件。
  • src/main/webapp/:包含 Web 应用的资源文件。
    • WEB-INF/views/:包含 Thymeleaf 模板文件。
    • resources/:包含静态资源文件,如 CSS、JavaScript 等。
  • src/test/java/:包含项目的测试代码。
  • pom.xml:Maven 项目的配置文件。

2. 项目的启动文件介绍

项目的启动文件是 Application.java,位于 src/main/java/org/thymeleaf/examples/petclinic/ 目录下。

Application.java 文件内容

package org.thymeleaf.examples.petclinic;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

启动文件介绍

  • @SpringBootApplication:这是一个组合注解,包含了 @Configuration@EnableAutoConfiguration@ComponentScan 注解,用于简化 Spring Boot 应用的配置。
  • main 方法:这是应用的入口点,通过调用 SpringApplication.run 方法来启动 Spring Boot 应用。

3. 项目的配置文件介绍

项目的配置文件是 application.properties,位于 src/main/resources/ 目录下。

application.properties 文件内容

# ===============================
# = THYMELEAF
# ===============================
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

# ===============================
# = DATASOURCE
# ===============================
spring.datasource.url=jdbc:hsqldb:mem:petclinic
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class

thymeleafexamples-petclinicSpring PetClinic + Thymeleaf- Companion application for the "Bringing Thymeleaf and Natural Templates to the Spring PetClinic" article at the Thymeleaf website: http://www.thymeleaf.org/doc/articles/petclinic.html项目地址:https://gitcode.com/gh_mirrors/th/thymeleafexamples-petclinic

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

江涛奎Stranger

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值