diff --git a/backend-java/README.md b/backend-java/README.md
new file mode 100644
index 0000000..1dc3cb2
--- /dev/null
+++ b/backend-java/README.md
@@ -0,0 +1,148 @@
+# 宁夏智慧养殖监管平台 - Java后端
+
+这是宁夏智慧养殖监管平台的Java微服务版本后端实现,使用Spring Boot框架构建。
+
+## 技术栈
+
+- **Java版本**: Java 17
+- **框架**: Spring Boot 3.1.0
+- **安全框架**: Spring Security
+- **数据库**: MySQL 8.0+
+- **ORM框架**: Spring Data JPA (Hibernate)
+- **API文档**: Springdoc OpenAPI (Swagger 3)
+- **认证**: JWT (JSON Web Tokens)
+- **密码加密**: BCrypt
+- **构建工具**: Maven
+- **服务器端口**: 5350
+
+## 项目结构
+
+```
+backend-java/
+├── src/
+│ ├── main/
+│ │ ├── java/
+│ │ │ └── com/nxxmdata/farmmonitor/
+│ │ │ ├── Application.java # 应用启动类
+│ │ │ ├── config/ # 配置类
+│ │ │ ├── controller/ # 控制器层
+│ │ │ ├── service/ # 服务层
+│ │ │ ├── repository/ # 数据访问层
+│ │ │ ├── model/ # 数据模型
+│ │ │ ├── dto/ # 数据传输对象
+│ │ │ ├── security/ # 安全相关
+│ │ │ └── exception/ # 异常处理
+│ │ └── resources/
+│ │ ├── application.yml # 应用配置
+│ │ └── application-dev.yml # 开发环境配置
+│ └── test/ # 测试代码
+├── pom.xml # Maven配置文件
+└── README.md # 项目说明文档
+```
+
+## 功能模块
+
+1. **用户认证模块**
+ - 用户登录/注册
+ - JWT Token生成与验证
+ - 密码加密存储
+
+2. **用户管理模块**
+ - 用户信息管理
+ - 角色权限管理
+
+3. **农场管理模块**
+ - 农场信息管理
+ - 地理位置信息处理
+
+4. **设备监控模块**
+ - 设备状态监控
+ - 传感器数据处理
+
+5. **动物管理模块**
+ - 动物档案管理
+ - 健康状态跟踪
+
+6. **预警管理模块**
+ - 系统告警处理
+ - 告警规则配置
+
+7. **订单管理模块**
+ - 产品销售管理
+ - 订单处理流程
+
+8. **统计分析模块**
+ - 数据统计分析
+ - 报表生成
+
+## API文档
+
+启动服务后,可通过以下地址访问API文档:
+
+- Swagger UI: http://localhost:5350/swagger-ui.html
+- OpenAPI JSON: http://localhost:5350/v3/api-docs
+
+## 数据库配置
+
+在 `application.yml` 文件中配置数据库连接:
+
+```yaml
+spring:
+ datasource:
+ url: jdbc:mysql://192.168.0.240:3307/nxxmdata?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
+ username: root
+ password: aiot$Aiot123
+ driver-class-name: com.mysql.cj.jdbc.Driver
+```
+
+## 快速开始
+
+### 环境要求
+
+- Java 17+
+- Maven 3.6+
+- MySQL 8.0+
+
+### 构建项目
+
+```bash
+mvn clean package
+```
+
+### 运行项目
+
+```bash
+mvn spring-boot:run
+```
+
+或者
+
+```bash
+java -jar target/farm-monitor-1.0.0.jar
+```
+
+## 开发规范
+
+1. 遵循RESTful API设计规范
+2. 使用JWT进行无状态认证
+3. 密码使用BCrypt加密存储
+4. 代码注释规范清晰
+5. API文档完整
+
+## 安全设计
+
+1. 使用JWT Token进行身份验证
+2. 密码使用BCrypt加密存储
+3. 基于角色的访问控制(RBAC)
+4. SQL注入防护(使用JPA)
+5. XSS防护(前端处理)
+
+## 性能优化
+
+1. 数据库连接池配置
+2. Hibernate二级缓存(可选)
+3. API响应时间监控
+4. 数据库查询优化
+
+---
+*最后更新: 2025年9月*
\ No newline at end of file
diff --git a/backend-java/pom.xml b/backend-java/pom.xml
new file mode 100644
index 0000000..3af9c75
--- /dev/null
+++ b/backend-java/pom.xml
@@ -0,0 +1,144 @@
+
+
+ 4.0.0
+
+ com.nxxmdata
+ farm-monitor
+ 1.0.0
+ jar
+
+ 宁夏智慧养殖监管平台
+ 宁夏智慧养殖监管平台Java微服务版本
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.1.0
+
+
+
+
+ 17
+ 2022.0.3
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+
+ io.jsonwebtoken
+ jjwt-api
+ 0.11.5
+
+
+
+ io.jsonwebtoken
+ jjwt-impl
+ 0.11.5
+ runtime
+
+
+
+ io.jsonwebtoken
+ jjwt-jackson
+ 0.11.5
+ runtime
+
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.33
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend-java/src/main/java/Application.java b/backend-java/src/main/java/Application.java
new file mode 100644
index 0000000..9b84ed4
--- /dev/null
+++ b/backend-java/src/main/java/Application.java
@@ -0,0 +1,14 @@
+package com.nxxmdata.farmmonitor;
+
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.info.Info;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@OpenAPIDefinition(info = @Info(title = "宁夏智慧养殖监管平台", version = "1.0", description = "宁夏智慧养殖监管平台API文档"))
+public class Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SecurityConfig.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SecurityConfig.java
new file mode 100644
index 0000000..d33038d
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SecurityConfig.java
@@ -0,0 +1,51 @@
+package com.nxxmdata.farmmonitor.config;
+
+import com.nxxmdata.farmmonitor.security.JwtAuthenticationFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
+import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+@Configuration
+@EnableWebSecurity
+@EnableMethodSecurity
+public class SecurityConfig {
+
+ @Autowired
+ private JwtAuthenticationFilter jwtAuthenticationFilter;
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
+ return config.getAuthenticationManager();
+ }
+
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+ http.cors().and().csrf().disable()
+ .authorizeHttpRequests(authz -> authz
+ .requestMatchers("/api/auth/**").permitAll()
+ .requestMatchers("/api-docs/**").permitAll()
+ .requestMatchers("/swagger-ui/**").permitAll()
+ .anyRequest().authenticated()
+ )
+ .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
+
+ http.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
+
+ return http.build();
+ }
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SwaggerConfig.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SwaggerConfig.java
new file mode 100644
index 0000000..34779b4
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/config/SwaggerConfig.java
@@ -0,0 +1,33 @@
+package com.nxxmdata.farmmonitor.config;
+
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import io.swagger.v3.oas.models.security.SecurityRequirement;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SwaggerConfig {
+
+ @Bean
+ public OpenAPI customOpenAPI() {
+ return new OpenAPI()
+ .info(new Info()
+ .title("宁夏智慧养殖监管平台 API")
+ .version("1.0.0")
+ .description("宁夏智慧养殖监管平台后端API文档")
+ .license(new License().name("Apache 2.0")
+ .url("http://springdoc.org")))
+ .addSecurityItem(new SecurityRequirement().addList("bearerAuth"))
+ .components(new Components()
+ .addSecuritySchemes("bearerAuth",
+ new SecurityScheme()
+ .name("bearerAuth")
+ .type(SecurityScheme.Type.HTTP)
+ .scheme("bearer")
+ .bearerFormat("JWT")));
+ }
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/controller/AuthController.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/controller/AuthController.java
new file mode 100644
index 0000000..f27a74d
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/controller/AuthController.java
@@ -0,0 +1,68 @@
+package com.nxxmdata.farmmonitor.controller;
+
+import com.nxxmdata.farmmonitor.dto.AuthRequest;
+import com.nxxmdata.farmmonitor.dto.AuthResponse;
+import com.nxxmdata.farmmonitor.dto.RegisterRequest;
+import com.nxxmdata.farmmonitor.model.User;
+import com.nxxmdata.farmmonitor.service.AuthService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/api/auth")
+@Tag(name = "Authentication", description = "用户认证相关接口")
+public class AuthController {
+
+ @Autowired
+ private AuthService authService;
+
+ @PostMapping("/login")
+ @Operation(summary = "用户登录", description = "用户登录接口,成功后返回JWT Token")
+ public ResponseEntity login(@Valid @RequestBody AuthRequest authRequest) {
+ String token = authService.authenticateUser(authRequest.getUsername(), authRequest.getPassword());
+
+ AuthResponse response = new AuthResponse();
+ if (token != null) {
+ response.setSuccess(true);
+ response.setMessage("登录成功");
+ response.setToken(token);
+
+ // 获取用户信息(不包含密码)
+ // 在实际应用中,应该从数据库查询用户信息
+ User user = new User();
+ user.setUsername(authRequest.getUsername());
+ response.setUser(user);
+ } else {
+ response.setSuccess(false);
+ response.setMessage("用户名或密码错误");
+ }
+
+ return ResponseEntity.ok(response);
+ }
+
+ @PostMapping("/register")
+ @Operation(summary = "用户注册", description = "用户注册接口")
+ public ResponseEntity register(@Valid @RequestBody RegisterRequest registerRequest) {
+ User user = authService.registerUser(
+ registerRequest.getUsername(),
+ registerRequest.getEmail(),
+ registerRequest.getPassword()
+ );
+
+ AuthResponse response = new AuthResponse();
+ if (user != null) {
+ response.setSuccess(true);
+ response.setMessage("注册成功");
+ response.setUser(user);
+ } else {
+ response.setSuccess(false);
+ response.setMessage("用户已存在");
+ }
+
+ return ResponseEntity.ok(response);
+ }
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthRequest.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthRequest.java
new file mode 100644
index 0000000..47b19f8
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthRequest.java
@@ -0,0 +1,9 @@
+package com.nxxmdata.farmmonitor.dto;
+
+import lombok.Data;
+
+@Data
+public class AuthRequest {
+ private String username;
+ private String password;
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthResponse.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthResponse.java
new file mode 100644
index 0000000..d4f694a
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/AuthResponse.java
@@ -0,0 +1,12 @@
+package com.nxxmdata.farmmonitor.dto;
+
+import com.nxxmdata.farmmonitor.model.User;
+import lombok.Data;
+
+@Data
+public class AuthResponse {
+ private boolean success;
+ private String message;
+ private String token;
+ private User user;
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/RegisterRequest.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/RegisterRequest.java
new file mode 100644
index 0000000..ec9a690
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/dto/RegisterRequest.java
@@ -0,0 +1,10 @@
+package com.nxxmdata.farmmonitor.dto;
+
+import lombok.Data;
+
+@Data
+public class RegisterRequest {
+ private String username;
+ private String email;
+ private String password;
+}
\ No newline at end of file
diff --git a/backend-java/src/main/java/com/nxxmdata/farmmonitor/exception/GlobalExceptionHandler.java b/backend-java/src/main/java/com/nxxmdata/farmmonitor/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..ff9d299
--- /dev/null
+++ b/backend-java/src/main/java/com/nxxmdata/farmmonitor/exception/GlobalExceptionHandler.java
@@ -0,0 +1,47 @@
+package com.nxxmdata.farmmonitor.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.context.request.WebRequest;
+
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.Map;
+
+@ControllerAdvice
+public class GlobalExceptionHandler {
+
+ @ExceptionHandler(UsernameNotFoundException.class)
+ public ResponseEntity