开源项目教程:Clean Architecture Example Java Spring Boot

开源项目教程:Clean Architecture Example Java Spring Boot

clean-architecture-example-java-spring-bootMy interpretation of Clean Architecture with Spring Boot项目地址:https://gitcode.com/gh_mirrors/cl/clean-architecture-example-java-spring-boot

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

项目的目录结构如下:

clean-architecture-example-java-spring-boot
├── src
│   ├── main
│   │   ├── java
│   │   │   ├── com
│   │   │   │   ├── example
│   │   │   │   │   ├── application
│   │   │   │   │   │   ├── ports
│   │   │   │   │   │   │   ├── incoming
│   │   │   │   │   │   │   │   ├── use_cases
│   │   │   │   │   │   │   │   │   ├── add_customer
│   │   │   │   │   │   │   │   │   ├── get_customer
│   │   │   │   │   │   │   │   │   ├── remove_customer
│   │   │   │   │   │   │   │   │   └── update_customer
│   │   │   │   │   │   │   └── outgoing
│   │   │   │   │   │   │       └── customer_repository
│   │   │   │   │   │   └── services
│   │   │   │   │   ├── domain
│   │   │   │   │   │   └── entities
│   │   │   │   │   ├── infrastructure
│   │   │   │   │   │   ├── config
│   │   │   │   │   │   ├── controllers
│   │   │   │   │   │   ├── persistence
│   │   │   │   │   │   │   ├── h2
│   │   │   │   │   │   │   ├── jpa
│   │   │   │   │   │   │   └── mappers
│   │   │   │   │   │   └── security
│   │   │   │   │   └── web
│   │   │   └── resources
│   │   │       ├── application.properties
│   │   │       └── schema.sql
│   └── test
│       └── java
│           └── com
│               └── example
│                   └── application
│                       └── services
└── pom.xml

目录结构介绍

  • src/main/java/com/example/application: 包含应用的核心逻辑,包括用例、服务和端口。
  • src/main/java/com/example/domain: 包含领域模型和实体。
  • src/main/java/com/example/infrastructure: 包含基础设施代码,如配置、控制器、持久化和安全相关代码。
  • src/main/resources: 包含应用的配置文件和数据库初始化脚本。
  • src/test/java: 包含测试代码。
  • pom.xml: Maven项目配置文件。

2. 项目的启动文件介绍

项目的启动文件是 src/main/java/com/example/web/CleanArchitectureExampleApplication.java。这个文件是Spring Boot应用的入口点,负责启动整个应用。

package com.example.web;

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

@SpringBootApplication
public class CleanArchitectureExampleApplication {

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

3. 项目的配置文件介绍

项目的配置文件是 src/main/resources/application.properties。这个文件包含了应用的各种配置,如数据库连接、服务器端口等。

# 服务器端口
server.port=8080

# 数据库配置
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

# H2控制台配置
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

# 日志配置
logging.level.org.springframework=INFO
logging.level.com.example=DEBUG

以上是关于 `Clean Architecture Example Java Spring

clean-architecture-example-java-spring-bootMy interpretation of Clean Architecture with Spring Boot项目地址:https://gitcode.com/gh_mirrors/cl/clean-architecture-example-java-spring-boot

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

瞿晟垣

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

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

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

打赏作者

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

抵扣说明:

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

余额充值