spring-boot-examples
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。
Top Related Projects
Spring Boot
Just Announced - "Learn Spring Security OAuth":
spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。
《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!
🚀一个用来深入学习并实战 Spring Boot 的项目。
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Quick Overview
The ityouknow/spring-boot-examples
repository is a collection of sample projects built using the Spring Boot framework. It provides a comprehensive set of examples that demonstrate the various features and capabilities of Spring Boot, making it a valuable resource for developers who are learning or working with the framework.
Pros
- Comprehensive Examples: The repository covers a wide range of Spring Boot use cases, from basic web applications to more advanced topics like security, messaging, and microservices.
- Well-Documented: Each example includes a detailed README file that explains the purpose, setup, and key features of the project.
- Active Maintenance: The repository is actively maintained, with regular updates and bug fixes.
- Community Engagement: The project has a strong community of contributors and users, providing a platform for collaboration and knowledge sharing.
Cons
- Potential Outdated Versions: Some of the examples may use older versions of Spring Boot or related technologies, which could require additional effort to update to the latest versions.
- Lack of Detailed Explanations: While the README files provide a good overview, they may not always go into deep technical details for each example.
- Scattered Organization: The repository contains a large number of examples, which can make it challenging to navigate and find specific use cases.
- Limited Deployment Guidance: The examples focus on the code itself, but may not provide comprehensive guidance on deployment and production-ready configurations.
Code Examples
Example 1: Basic Web Application
@SpringBootApplication
public class BasicWebApplication {
public static void main(String[] args) {
SpringApplication.run(BasicWebApplication.class, args);
}
@RestController
public class HelloController {
@GetMapping("/")
public String hello() {
return "Hello, Spring Boot!";
}
}
}
This example demonstrates a basic Spring Boot web application that exposes a simple GET
endpoint at the root URL, returning the message "Hello, Spring Boot!".
Example 2: Security Configuration
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/user/**").hasRole("USER")
.anyRequest().authenticated()
.and()
.formLogin()
.and()
.logout();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("admin").password("{noop}password").roles("ADMIN")
.and()
.withUser("user").password("{noop}password").roles("USER");
}
}
This example demonstrates a basic security configuration for a Spring Boot application, where the /admin/**
endpoints are accessible only to users with the "ADMIN" role, and the /user/**
endpoints are accessible only to users with the "USER" role.
Example 3: Messaging with RabbitMQ
@SpringBootApplication
public class RabbitMQApplication {
public static void main(String[] args) {
SpringApplication.run(RabbitMQApplication.class, args);
}
@Component
public class MessageSender {
@Autowired
private RabbitTemplate rabbitTemplate;
public void sendMessage(String message) {
rabbitTemplate.convertAndSend("my-exchange", "my-routing-key", message);
}
}
@Component
public class MessageReceiver {
@RabbitListener(queues = "my-queue")
public void receiveMessage(String message) {
System.out.println("Received message: " + message);
}
}
}
This example demonstrates how to use RabbitMQ for messaging in a Spring Boot application. The MessageSender
class sends a message to the RabbitMQ exchange, and the MessageReceiver
class listens for messages on a specific queue and logs the received message.
Getting Started
To get started with the `ityouknow/spring-boot-
Competitor Comparisons
Spring Boot
Pros of spring-boot
- Official Spring Boot repository, providing the core framework and documentation
- Extensive test coverage and continuous integration
- Regular updates and releases with detailed changelogs
Cons of spring-boot
- Steeper learning curve for beginners due to its comprehensive nature
- Less focus on practical examples and real-world use cases
- May be overwhelming for developers seeking quick, specific implementations
Code Comparison
spring-boot (Configuration class):
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
spring-boot-examples (HelloWorld controller):
@RestController
public class HelloWorldController {
@RequestMapping("/hello")
public String index() {
return "Hello World";
}
}
The spring-boot repository focuses on core framework code, while spring-boot-examples provides practical implementations and tutorials for various Spring Boot features. spring-boot is ideal for understanding the framework's internals and contributing to its development, whereas spring-boot-examples is better suited for learning and quick reference when building Spring Boot applications.
Just Announced - "Learn Spring Security OAuth":
Pros of tutorials
- Broader scope, covering various Java frameworks and technologies beyond Spring Boot
- More comprehensive, with a larger number of examples and tutorials
- Regular updates and active community engagement
Cons of tutorials
- Can be overwhelming due to the vast amount of content
- May lack the focused, in-depth Spring Boot coverage found in spring-boot-examples
Code Comparison
spring-boot-examples:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
tutorials:
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Summary
Both repositories offer valuable resources for Java developers. spring-boot-examples provides a focused approach to Spring Boot, making it ideal for those specifically interested in this framework. tutorials, on the other hand, offers a wider range of topics and examples, catering to developers looking to explore various Java technologies.
The code comparison shows that both repositories use similar basic Spring Boot application structures, with tutorials demonstrating a more explicit configuration approach. Ultimately, the choice between these repositories depends on the developer's specific learning goals and preferences.
spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。
Pros of springboot-learning-example
- More comprehensive coverage of Spring Boot features, including advanced topics like Spring Cloud and microservices
- Better organized structure with clear categorization of examples
- More frequent updates and active maintenance
Cons of springboot-learning-example
- Less beginner-friendly, with fewer explanations and comments in the code
- Smaller community engagement, with fewer stars and forks on GitHub
- Some examples may be outdated or not aligned with the latest Spring Boot best practices
Code Comparison
spring-boot-examples:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
springboot-learning-example:
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The main difference in the code snippets is that springboot-learning-example includes the @EnableScheduling
annotation, demonstrating more advanced configuration options in its examples.
《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!
Pros of SpringBoot-Learning
- More comprehensive coverage of Spring Boot topics
- Better organization with separate branches for different Spring Boot versions
- Includes more advanced topics like microservices and cloud deployment
Cons of SpringBoot-Learning
- Less frequent updates compared to spring-boot-examples
- Fewer contributors, potentially limiting diverse perspectives
- Some examples may be outdated for the latest Spring Boot versions
Code Comparison
SpringBoot-Learning:
@SpringBootApplication
@EnableDiscoveryClient
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}
spring-boot-examples:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The SpringBoot-Learning example includes @EnableDiscoveryClient
, demonstrating integration with service discovery, while spring-boot-examples keeps it simpler with just the basic @SpringBootApplication
annotation.
Both repositories offer valuable resources for learning Spring Boot, with SpringBoot-Learning providing more depth and spring-boot-examples offering a broader range of simpler examples. The choice between them depends on the learner's experience level and specific learning goals.
🚀一个用来深入学习并实战 Spring Boot 的项目。
Pros of spring-boot-demo
- More comprehensive coverage of Spring Boot features and integrations
- Better organized project structure with clear module separation
- More frequent updates and active maintenance
Cons of spring-boot-demo
- Potentially overwhelming for beginners due to its extensive scope
- Less focused on basic Spring Boot concepts compared to spring-boot-examples
Code Comparison
spring-boot-demo:
@SpringBootApplication
@EnableScheduling
@EnableAsync
public class SpringBootDemoTaskApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootDemoTaskApplication.class, args);
}
}
spring-boot-examples:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The spring-boot-demo example includes additional annotations for enabling scheduling and asynchronous execution, demonstrating a more feature-rich approach. In contrast, the spring-boot-examples code showcases a simpler, more straightforward implementation focusing on core Spring Boot functionality.
Both repositories serve as valuable resources for learning Spring Boot, with spring-boot-demo offering a wider range of advanced topics and integrations, while spring-boot-examples provides a more accessible entry point for newcomers to the framework.
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统 包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Pros of mall
- Comprehensive e-commerce solution with a wide range of features
- Well-structured and modular architecture for scalability
- Detailed documentation and deployment guides
Cons of mall
- Steeper learning curve due to its complexity
- May be overkill for simpler projects or learning purposes
- Requires more resources to run and maintain
Code comparison
mall:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated();
}
}
spring-boot-examples:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
}
}
The mall project provides a more comprehensive security configuration, including CSRF protection and session management, while spring-boot-examples offers a simpler setup focused on basic authentication and authorization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Spring Boot å¦ä¹ 示ä¾
Spring Boot 使ç¨çåç§ç¤ºä¾ï¼ä»¥æç®åãæå®ç¨ä¸ºæ åï¼æ¤å¼æºé¡¹ç®ä¸çæ¯ä¸ªç¤ºä¾é½ä»¥æå°ä¾èµï¼æç®å为æ åï¼å¸®å©åå¦è å¿«éææ¡ Spring Boot åç»ä»¶ç使ç¨ã
Spring Boot ä¸æç´¢å¼ | Spring Cloudå¦ä¹ 示ä¾ä»£ç | Spring Boot ç²¾å课ç¨
Githubå°å | ç äºå°å | Spring Boot 1.X | Spring Boot 2.X
æ¬é¡¹ç®ä¸ææ示ä¾åå·²ç»æ´æ°å° Spring Boot 3.0
- Spring Boot 1.X ç³»å示ä¾ä»£ç 请çè¿éï¼Spring Boot 1.X
- Spring Boot 2.X ç³»å示ä¾ä»£ç 请çè¿éï¼Spring Boot 2.X
示ä¾ä»£ç
- spring-boot-helloï¼Spring Boot 3.0 Hello World 示ä¾
- spring-boot-bannerï¼Spring Boot 3.0 å®å¶ banner 示ä¾
- spring-boot-helloworldï¼Spring Boot 3.0 Hello World Test åå æµè¯ç¤ºä¾
- spring-boot-schedulerï¼Spring Boot 3.0 å®æ¶ä»»å¡ scheduler 使ç¨ç¤ºä¾
- spring-boot-packageï¼Spring Boot 3.0 åå æµè¯ãéææµè¯ãæ Jar/War å ãå®å¶å¯å¨åæ°ä½¿ç¨æ¡ä¾
- spring-boot-commandLineRunnerï¼Spring Boot 3.0 ç®å¯å¨æ¶åå§åèµæºæ¡ä¾
- spring-boot-webï¼Spring Boot 3.0 web 示ä¾
- spring-boot-webfluxï¼Spring Boot 3.0 ååºå¼ç¼ç¨ WebFlux 使ç¨æ¡ä¾
- spring-boot-file-uploadï¼Spring Boot 3.0 ä¸ä¼ æ件使ç¨æ¡ä¾
- spring-boot-thymeleafï¼Spring Boot 3.0 Thymeleaf è¯æ³ãå¸å±ä½¿ç¨ç¤ºä¾
- spring-boot-jpaï¼Spring Boot 3.0 Jpa æä½ãå¢å ãæ¹æ¥å¤æ°æ®æºä½¿ç¨ç¤ºä¾
- spring-boot-mybatisï¼Spring Boot 3.0 Mybatis 注解ãxml 使ç¨ãå¢å æ¹æ¥ãå¤æ°æ®æºä½¿ç¨ç¤ºä¾
- spring-boot-web-thymeleafï¼Spring Boot 3.0 thymeleaf å¢å 该æ¥ç¤ºä¾
- spring-boot-jpa-thymeleaf-curdï¼Spring Boot 3.0 Jpa thymeleaf å表ãå¢å æ¹æ¥ä½¿ç¨æ¡ä¾
- spring-boot-mailï¼Spring Boot 3.0 é®ä»¶åé使ç¨ç¤ºä¾
- spring-boot-rabbitmqï¼Spring Boot 3.0 RabbitMQ åç§å¸¸è§åºæ¯ä½¿ç¨ç¤ºä¾
- spring-boot-mongodbï¼Spring Boot 3.0 MongoDB å¢å æ¹æ¥ç¤ºä¾ å¤æ°æ®æºä½¿ç¨æ¡ä¾
- spring-boot-redisï¼Spring Boot 3.0 Redis 示ä¾
- spring-boot-memcache-spymemcachedï¼Spring Boot 3.0 éæ Memcached 使ç¨æ¡ä¾
- spring-boot-dockerï¼Spring Boot 3.0 Docker 使ç¨æ¡ä¾
- dockercompose-springboot-mysql-nginxï¼Spring Boot 3.0 Docker Compose + Spring Boot + Nginx + Mysql 使ç¨æ¡ä¾
å¦æ大家æ³äºè§£å ³äº Spring Boot çå ¶å®æ¹é¢åºç¨ï¼ä¹å¯ä»¥ä»¥issuesçå½¢å¼åé¦ç»æï¼æåç»æ¥å®åã
å ³æ³¨å ¬ä¼å·ï¼çº¯æ´çå¾®ç¬ï¼åå¤"666"è¿ç¾¤äº¤æµ
Top Related Projects
Spring Boot
Just Announced - "Learn Spring Security OAuth":
spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。
《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!
🚀一个用来深入学习并实战 Spring Boot 的项目。
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot