Convert Figma logo to code with AI

xkcoding logospring-boot-demo

🚀一个用来深入学习并实战 Spring Boot 的项目。

32,843
10,816
32,843
132

Top Related Projects

Spring Boot

spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。

about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!

40,006

🔥「企业级低代码平台」前后端分离架构SpringBoot 2.x/3.x,SpringCloud,Ant Design&Vue3,Mybatis,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。

77,204

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

Quick Overview

Spring Boot Demo is a comprehensive collection of examples and best practices for building applications with Spring Boot. It covers a wide range of topics, from basic setup to advanced features, making it an excellent resource for developers looking to learn or improve their skills with Spring Boot.

Pros

  • Extensive coverage of Spring Boot features and integrations
  • Well-organized project structure with clear examples for each topic
  • Regularly updated to include the latest Spring Boot versions and features
  • Includes both basic and advanced topics, catering to developers of all skill levels

Cons

  • Large repository size may be overwhelming for beginners
  • Some examples may lack detailed explanations or comments
  • Not all examples are available in multiple languages (primarily in Chinese)
  • Some advanced topics might require additional background knowledge

Code Examples

  1. Basic Spring Boot application setup:
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
  1. RESTful API endpoint example:
@RestController
@RequestMapping("/api")
public class UserController {
    @GetMapping("/users")
    public List<User> getAllUsers() {
        // Implementation to fetch and return users
    }
}
  1. Database integration with Spring Data JPA:
@Entity
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String email;
    // Getters and setters
}

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    List<User> findByName(String name);
}

Getting Started

To get started with Spring Boot Demo:

  1. Clone the repository:

    git clone https://github.com/xkcoding/spring-boot-demo.git
    
  2. Navigate to the desired example directory:

    cd spring-boot-demo/demo-helloworld
    
  3. Run the application using Maven:

    mvn spring-boot:run
    
  4. Access the application in your web browser or API client, typically at http://localhost:8080

For more detailed instructions and specific examples, refer to the README files in each subdirectory of the project.

Competitor Comparisons

Spring Boot

Pros of Spring Boot

  • Official Spring Boot repository with extensive documentation and community support
  • Regularly updated with new features, bug fixes, and security patches
  • Comprehensive test coverage and production-ready code

Cons of Spring Boot

  • Larger codebase, which may be overwhelming for beginners
  • Focuses on core functionality rather than specific use cases or examples
  • Steeper learning curve for those new to Spring ecosystem

Code Comparison

Spring Boot (core functionality):

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

Spring Boot Demo (example implementation):

@SpringBootApplication
@RestController
public class DemoApplication {
    @GetMapping("/hello")
    public String hello() {
        return "Hello, Spring Boot!";
    }

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

Summary

Spring Boot is the official repository, offering a robust and well-maintained framework for building Spring applications. It provides extensive documentation and regular updates but may be challenging for beginners due to its comprehensive nature.

Spring Boot Demo, on the other hand, focuses on providing practical examples and use cases, making it easier for developers to understand and implement specific features. However, it may not cover all aspects of Spring Boot or receive updates as frequently as the official repository.

spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。

Pros of springboot-learning-example

  • More comprehensive coverage of Spring Boot features, including advanced topics
  • Better organized structure with clear categorization of examples
  • Includes detailed explanations and comments in Chinese, beneficial for Chinese-speaking developers

Cons of springboot-learning-example

  • Less frequently updated compared to spring-boot-demo
  • Fewer integration examples with popular third-party libraries
  • Some examples may be outdated due to the project's age

Code Comparison

spring-boot-demo:

@SpringBootApplication
@MapperScan(basePackages = {"com.xkcoding.mybatis.mapper"})
public class MybatisApplication {
    public static void main(String[] args) {
        SpringApplication.run(MybatisApplication.class, args);
    }
}

springboot-learning-example:

@SpringBootApplication
@MapperScan("com.didispace.mybatis.mapper")
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Both examples demonstrate similar basic setup for a Spring Boot application with MyBatis integration. The main difference lies in the package structure and naming conventions used in each project.

about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

Pros of spring-boot-examples

  • More comprehensive coverage of Spring Boot features and integrations
  • Better organized structure with clear categorization of examples
  • Includes examples for Spring Cloud and microservices architecture

Cons of spring-boot-examples

  • Less frequent updates compared to spring-boot-demo
  • Some examples may be outdated or not compatible with the latest Spring Boot version
  • Lacks some modern features and integrations present in spring-boot-demo

Code Comparison

spring-boot-examples:

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

spring-boot-demo:

@SpringBootApplication
@EnableScheduling
public class SpringBootDemoTaskApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootDemoTaskApplication.class, args);
    }
}

The code comparison shows that spring-boot-demo includes additional annotations and configurations, such as @EnableScheduling, which demonstrates its focus on more specific use cases and advanced features.

Both repositories serve as valuable resources for learning Spring Boot, with spring-boot-examples offering a broader range of examples and spring-boot-demo providing more up-to-date and specialized implementations.

《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!

Pros of SpringBoot-Learning

  • More comprehensive coverage of Spring Boot topics, including advanced concepts
  • Better organized structure with clear categorization of examples
  • Regularly updated with new Spring Boot features and best practices

Cons of SpringBoot-Learning

  • Less focus on practical, real-world application scenarios
  • Fewer integration examples with third-party libraries and tools
  • May be overwhelming for beginners due to its extensive content

Code Comparison

SpringBoot-Learning:

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

spring-boot-demo:

@SpringBootApplication
@MapperScan(basePackages = "com.xkcoding.mybatis.mapper")
public class MybatisApplication {
    public static void main(String[] args) {
        SpringApplication.run(MybatisApplication.class, args);
    }
}

The code comparison shows that SpringBoot-Learning focuses on core Spring Boot features like scheduling, while spring-boot-demo demonstrates integration with specific technologies like MyBatis.

Both repositories offer valuable resources for learning Spring Boot, with SpringBoot-Learning providing a more comprehensive guide and spring-boot-demo offering more practical, focused examples. The choice between them depends on the learner's experience level and specific learning goals.

40,006

🔥「企业级低代码平台」前后端分离架构SpringBoot 2.x/3.x,SpringCloud,Ant Design&Vue3,Mybatis,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。

Pros of JeecgBoot

  • More comprehensive enterprise-level solution with built-in low-code platform
  • Extensive documentation and active community support
  • Includes advanced features like code generation and workflow management

Cons of JeecgBoot

  • Steeper learning curve due to its complexity
  • May be overkill for smaller projects or simple applications
  • Less flexibility for customization compared to a bare-bones Spring Boot setup

Code Comparison

JeecgBoot (using its code generation feature):

@RestController
@RequestMapping("/demo")
@Slf4j
public class DemoController {
    @Autowired
    private IDemoService demoService;
    
    @GetMapping(value = "/list")
    public Result<?> list(DemoEntity demo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        return Result.OK(demoService.list(demo, pageNo, pageSize));
    }
}

spring-boot-demo (basic REST controller):

@RestController
@RequestMapping("/api")
public class DemoController {
    @GetMapping("/hello")
    public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
        return String.format("Hello, %s!", name);
    }
}

JeecgBoot offers more out-of-the-box functionality, while spring-boot-demo provides a simpler starting point for custom development.

77,204

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

Pros of mall

  • More comprehensive e-commerce solution with frontend and backend components
  • Includes advanced features like Redis caching and Elasticsearch integration
  • Offers detailed documentation and deployment guides

Cons of mall

  • Higher complexity and steeper learning curve
  • May be overkill for simpler projects or learning purposes
  • Requires more resources to run and maintain

Code Comparison

mall (PmsProductController.java):

@ApiOperation("Create product")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody PmsProductParam productParam) {
    int count = productService.create(productParam);
    if (count > 0) {
        return CommonResult.success(count);
    } else {
        return CommonResult.failed();
    }
}

spring-boot-demo (UserController.java):

@PostMapping("/user")
public ResponseEntity<User> createUser(@RequestBody User user) {
    User savedUser = userRepository.save(user);
    return ResponseEntity.ok(savedUser);
}

The mall project demonstrates a more structured approach with API documentation and custom result handling, while spring-boot-demo showcases a simpler, more straightforward implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Spring Boot Demo

Travis-CI Codacy author JDK Spring Boot LICENSE

star star star

中文 | English

项目简介

spring boot demo 是一个用来深度学习并实战 spring boot 的项目,目前总共包含 66 个集成demo,已经完成 55 个。

该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求日志)、统一异常处理(json级别和页面级别)、freemarker(模板引擎)、thymeleaf(模板引擎)、Beetl(模板引擎)、Enjoy(模板引擎)、JdbcTemplate(通用JDBC操作数据库)、JPA(强大的ORM框架)、mybatis(强大的ORM框架)、通用Mapper(快速操作Mybatis)、PageHelper(通用的Mybatis分页插件)、mybatis-plus(快速操作Mybatis)、BeetlSQL(强大的ORM框架)、upload(本地文件上传和七牛云文件上传)、redis(缓存)、ehcache(缓存)、email(发送各种类型邮件)、task(基础定时任务)、quartz(动态管理定时任务)、xxl-job(分布式定时任务)、swagger(API接口管理测试)、security(基于RBAC的动态权限认证)、SpringSession(Session共享)、Zookeeper(结合AOP实现分布式锁)、RabbitMQ(消息队列)、Kafka(消息队列)、websocket(服务端推送监控服务器运行信息)、socket.io(聊天室)、ureport2(中国式报表)、打包成war文件、集成 ElasticSearch(基本操作和高级查询)、Async(异步任务)、集成Dubbo(采用官方的starter)、MongoDB(文档数据库)、neo4j(图数据库)、docker(容器化)、JPA多数据源、Mybatis多数据源、代码生成器、GrayLog(日志收集)、JustAuth(第三方登录)、LDAP(增删改查)、动态添加/切换数据源、单机限流(AOP + Guava RateLimiter)、分布式限流(AOP + Redis + Lua)、ElasticSearch 7.x(使用官方 Rest High Level Client)、HTTPS、Flyway(数据库初始化)、UReport2(中国式复杂报表)。

如果大家还有想要集成的demo,也可在 issue 里提需求。我会额外添加在 TODO 列表里。✊

分支介绍

  • master 分支:基于 Spring Boot 版本 2.1.0.RELEASE,每个 Module 的 parent 依赖根目录下的 pom.xml,主要用于管理每个 Module 的通用依赖版本,方便大家学习。
  • v-1.5.x 分支:基于 Spring Boot 版本 1.5.8.RELEASE,每个 Module 均依赖 spring-boot-demo-parent,有挺多同学们反映这种方式对新手不是很友好,运行起来有些难度,因此 此分支(v-1.5.x)会停止开发维护 ,所有内容会慢慢以 master 分支的形式同步过去,此分支暂未完成的,也会直接在 master 分支上加,在此分支学习的同学们,仍然可以在此分支学习,但是建议后期切换到master分支,会更加容易,毕竟官方已经将 Spring Boot 升级到 2.x 版本。🙂

开发环境

  • JDK 1.8 +
  • Maven 3.5 +
  • IntelliJ IDEA ULTIMATE 2018.2 + (注意:务必使用 IDEA 开发,同时保证安装 lombok 插件)
  • Mysql 5.7 + (尽量保证使用 5.7 版本以上,因为 5.7 版本加了一些新特性,同时不向下兼容。本 demo 里会尽量避免这种不兼容的地方,但还是建议尽量保证 5.7 版本以上)

运行方式

提示:如果是 fork 的朋友,同步代码的请参考:https://xkcoding.com/2018/09/18/how-to-update-the-fork-project.html

  1. git clone https://github.com/xkcoding/spring-boot-demo.git
  2. 使用 IDEA 打开 clone 下来的项目
  3. 在 IDEA 中 Maven Projects 的面板导入项目根目录下 的 pom.xml 文件
  4. Maven Projects 找不到的童鞋,可以勾上 IDEA 顶部工具栏的 View -> Tool Buttons ,然后 Maven Projects 的面板就会出现在 IDEA 的右侧
  5. 找到各个 Module 的 Application 类就可以运行各个 demo 了
  6. 注意:每个 demo 均有详细的 README 配套,食用 demo 前记得先看看哦~
  7. 注意:运行各个 demo 之前,有些是需要事先初始化数据库数据的,亲们别忘记了哦~

项目趋势

Stargazers over time

其他

团队纳新

组内招人啦,HC 巨多,Base 杭州,感兴趣的小伙伴,查看 岗位详情

开源推荐

11628591293_.pic_hd

开发计划

查看 TODO 文件

各 Module 介绍

Module 名称Module 介绍
demo-helloworldspring-boot 的一个 helloworld
demo-propertiesspring-boot 读取配置文件中的内容
demo-actuatorspring-boot 集成 spring-boot-starter-actuator 用于监控 spring-boot 的启动和运行状态
demo-admin-clientspring-boot 集成 spring-boot-admin 来可视化的监控 spring-boot 程序的运行状态,可以与 actuator 互相搭配使用,客户端示例
demo-admin-serverspring-boot 集成 spring-boot-admin 来可视化的监控 spring-boot 程序的运行状态,可以与 actuator 互相搭配使用,服务端示例
demo-logbackspring-boot 集成 logback 日志
demo-log-aopspring-boot 使用 AOP 切面的方式记录 web 请求日志
demo-exception-handlerspring-boot 统一异常处理,包括2种,第一种返回统一的 json 格式,第二种统一跳转到异常页面
demo-template-freemarkerspring-boot 集成 Freemarker 模板引擎
demo-template-thymeleafspring-boot 集成 Thymeleaf 模板引擎
demo-template-beetlspring-boot 集成 Beetl 模板引擎
demo-template-enjoyspring-boot 集成 Enjoy 模板引擎
demo-orm-jdbctemplatespring-boot 集成 Jdbc Template 操作数据库,并简易封装通用 Dao 层
demo-orm-jpaspring-boot 集成 spring-boot-starter-data-jpa 操作数据库
demo-orm-mybatisspring-boot 集成原生mybatis,使用 mybatis-spring-boot-starter 集成
demo-orm-mybatis-mapper-pagespring-boot 集成通用Mapper和PageHelper,使用 mapper-spring-boot-starter 和 pagehelper-spring-boot-starter 集成
demo-orm-mybatis-plusspring-boot 集成 mybatis-plus,使用 mybatis-plus-boot-starter 集成,集成 BaseMapper、BaseService、ActiveRecord 操作数据库
demo-orm-beetlsqlspring-boot 集成 beetl-sql,使用 beetl-framework-starter 集成
demo-uploadspring-boot 文件上传示例,包含本地文件上传以及七牛云文件上传
demo-cache-redisspring-boot 整合 redis,操作redis中的数据,并使用redis缓存数据
demo-cache-ehcachespring-boot 整合 ehcache,使用 ehcache 缓存数据
demo-emailspring-boot 整合 email,包括发送简单文本邮件、HTML邮件(包括模板HTML邮件)、附件邮件、静态资源邮件
demo-taskspring-boot 快速实现定时任务
demo-task-quartzspring-boot 整合 quartz,并实现对定时任务的管理,包括新增定时任务,删除定时任务,暂停定时任务,恢复定时任务,修改定时任务启动时间,以及定时任务列表查询,提供前端页面
demo-task-xxl-jobspring-boot 整合xxl-job,并提供绕过 xxl-job-admin 对定时任务的管理的方法,包括定时任务列表,触发器列表,新增定时任务,删除定时任务,停止定时任务,启动定时任务,修改定时任务,手动触发定时任务
demo-swaggerspring-boot 集成原生的 swagger 用于统一管理、测试 API 接口
demo-swagger-beautyspring-boot 集成第三方 swagger swagger-bootstrap-ui 美化API文档样式,用于统一管理、测试 API 接口
demo-rbac-securityspring-boot 集成 spring security 完成基于RBAC权限模型的权限管理,支持自定义过滤请求,动态权限认证,使用 JWT 安全认证,支持在线人数统计,手动踢出用户等操作
demo-rbac-shirospring-boot 集成 shiro 实现权限管理
待完成
demo-sessionspring-boot 集成 Spring Session 实现Session共享、重启程序Session不失效
demo-oauthspring-boot 实现 oauth 服务器功能,实现授权码机制
待完成
demo-socialspring-boot 集成第三方登录,集成 justauth-spring-boot-starter 实现QQ登录、GitHub登录、微信登录、谷歌登录、微软登录、小米登录、企业微信登录。
demo-zookeeperspring-boot 集成 Zookeeper 结合AOP实现分布式锁
demo-mq-rabbitmqspring-boot 集成 RabbitMQ 实现基于直接队列模式、分列模式、主题模式、延迟队列的消息发送和接收
demo-mq-rocketmqspring-boot 集成 RocketMQ,实现消息的发送和接收
待完成
demo-mq-kafkaspring-boot 集成 kafka,实现消息的发送和接收
demo-websocketspring-boot 集成 websocket,后端主动推送前端服务器运行信息
demo-websocket-socketiospring-boot 使用 netty-socketio 集成 websocket,实现一个简单的聊天室
demo-ureport2spring-boot 集成 ureport2 实现复杂的自定义的中国式报表
待完成
demo-uflospring-boot 集成 uflo 快速实现轻量级流程引擎
待完成
demo-urulespring-boot 集成 urule 快速实现规则引擎
待完成
demo-activitispring-boot 集成 activiti 7 流程引擎
待完成
demo-asyncspring-boot 使用原生提供的异步任务支持,实现异步执行任务
demo-warspring-boot 打成 war 包的配置
demo-elasticsearchspring-boot 集成 ElasticSearch,集成 spring-boot-starter-data-elasticsearch 完成对 ElasticSearch 的高级使用技巧,包括创建索引、配置映射、删除索引、增删改查基本操作、复杂查询、高级查询、聚合查询等
demo-dubbospring-boot 集成 Dubbo,分别为公共模块 spring-boot-demo-dubbo-common、服务提供方spring-boot-demo-dubbo-provider、服务调用方spring-boot-demo-dubbo-consumer
demo-mongodbspring-boot 集成 MongoDB,使用官方的 starter 实现增删改查
demo-neo4jspring-boot 集成 Neo4j 图数据库,实现一个校园人物关系网的demo
demo-dockerspring-boot 容器化
demo-multi-datasource-jpaspring-boot 使用JPA集成多数据源
demo-multi-datasource-mybatisspring-boot 使用Mybatis集成多数据源,使用 Mybatis-Plus 提供的开源解决方案实现
demo-sharding-jdbcspring-boot 使用 sharding-jdbc 实现分库分表,同时ORM采用 Mybatis-Plus
demo-tiospring-boot 集成 tio 网络编程框架
待完成
demo-grpcspring-boot 集成grpc,配置tls/ssl,参见ISSUE#5
待完成
demo-codegenspring-boot 集成 velocity 模板技术实现的代码生成器,简化开发
demo-graylogspring-boot 集成 graylog 实现日志统一收集
demo-ssospring-boot 集成 SSO 单点登录,参见 ISSUE#12
待完成
demo-ldapspring-boot 集成 LDAP,集成 spring-boot-starter-data-ldap 完成对 Ldap 的基本 CURD操作, 并给出以登录为实战的 API 示例,参见 ISSUE#23,感谢 @fxbin
demo-dynamic-datasourcespring-boot 动态添加数据源、动态切换数据源
demo-ratelimit-guavaspring-boot 使用 Guava RateLimiter 实现单机版限流,保护 API
demo-ratelimit-redisspring-boot 使用 Redis + Lua 脚本实现分布式限流,保护 API
demo-httpsspring-boot 集成 HTTPS
demo-elasticsearch-rest-high-level-clientspring boot 集成 ElasticSearch 7.x 版本,使用官方 Rest High Level Client 操作 ES 数据
demo-flywayspring boot 集成 Flyway,项目启动时初始化数据库表结构,同时支持数据库脚本版本控制
demo-ureport2spring boot 集成 Ureport2,实现中国式复杂报表设计

特别感谢

License

MIT

Copyright (c) 2018 Yangkai.Shen