This is a Java SpringBoot template for starting a new project that includes commonly used frameworks and example code for mainstream business. With this template, you can quickly set up the backend of a content website in just one minute. You can also use this as a foundation to develop your own project.
- Spring Boot 2.7.x
- Spring MVC
- MyBatis + MyBatis Plus
- Spring Boot
- Spring AOP
- Spring Scheduler
- Spring Transaction annotation
- MySQL
- Redis
- Elasticsearch
- COS(Cloud Object Storage)
- Easy Excel
- Hutool
- Gson
- Apache Commons Lang3
- Lombok
- Spring Session Redis(Distributed login)
- Global request response interceptor (logging)
- Global exception handler
- Custom error codes
- Encapsulation of common response classes
- Swagger + Knife4j API documentation
- Custom permission annotations + global validation
- Global cross-domain handling
- Resolving long integer precision loss
- Multiple environment configurations
- Provide example SQL (user, post, post like, post collection tables)
- User login, registration, logout, update, search, and permission management
- Post creation, deletion, editing, updating, database search, and flexible search using Elasticsearch
- Post liking and unliking
- Post collection, uncollection, and search for collected posts
- Full and incremental synchronization of posts with Elasticsearch using scheduled tasks
- Support for login via WeChat Open Platform
- Support for WeChat official account subscription, messaging, and menu settings
- Support for file uploads for different business domains
- JUnit5
All places that need to be modified are marked with
todo
~
1)Modify the database configuration in application.yml
to your own:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/my_db
username: root
password: 123456
2)Execute the database statements in sql/create_table.sql
to automatically create the database tables
3)Start the project, visit http://localhost:8101/api/doc.html to open the API documentation. You can debug the APIs online without the need for frontend development~
1)Modify the Redis Configuration in application.yml
to your own:
spring:
redis:
database: 1
host: localhost
port: 6379
timeout: 5000
password: 123456
2)Modify session storage mode in application.yml
to your own:
spring:
session:
store-type: redis
3)Remove exclude parameter from @SpringBootApplication
annotation at the beginning of the MainApplication
class:
Before modify:
@SpringBootApplication(exclude = {RedisAutoConfiguration.class})
After modify:
@SpringBootApplication
1)Modify the Elasticsearch Search Engineapplication.yml
to your own:
spring:
elasticsearch:
uris: http://localhost:9200
username: root
password: 123456
2)Copy the contents of the sql/post_es_mapping.json
file and create an index
(equivalent to creating a database table) by calling Elasticsearch's API or Kibana Dev Tools.
PUT post_v1
{
Parameters in sql/post_es_mapping.json
}
3)Start the synchronization task to synchronize posts from the database to Elasticsearch.
Locate the FullSyncPostToEs
and IncSyncPostToEs
files in the job directory,
uncomment the @Component
annotation, and execute the program again to trigger the synchronization:
// todo remove annotation
//@Component