fix: 修复部署问题
- 修复 RootController 返回 index.html - 修复 MyBatis 缓存配置 - 修复 session scope bean 注入问题
This commit is contained in:
@@ -1,13 +1,39 @@
|
||||
package com.example.scaffold.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@RestController
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class RootController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String root() {
|
||||
return "Spring Boot Scaffold is running!";
|
||||
public String index() {
|
||||
return "forward:/index.html";
|
||||
}
|
||||
|
||||
@GetMapping("/api/status")
|
||||
@ResponseBody
|
||||
public Map<String, Object> status() {
|
||||
return Map.of(
|
||||
"message", "Spring Boot 学习脚手架运行中",
|
||||
"pages", Map.of(
|
||||
"首页", "/index.html",
|
||||
"IoC学习", "/ioc.html",
|
||||
"AOP学习", "/aop.html",
|
||||
"MyBatis学习", "/mybatis.html",
|
||||
"事务学习", "/transaction.html",
|
||||
"用户管理", "/users.html",
|
||||
"API测试", "/api.html"
|
||||
),
|
||||
"apis", Map.of(
|
||||
"用户API", "/api/users",
|
||||
"产品API", "/api/products",
|
||||
"订单API", "/api/orders",
|
||||
"学习API", "/api/learning"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,8 @@ public class IocLearningController {
|
||||
private final PerformanceAspect performanceAspect;
|
||||
|
||||
// 演示字段注入(不推荐,但可以用)
|
||||
@Autowired
|
||||
@Qualifier("learningBean")
|
||||
private LearningBean learningBean;
|
||||
// 注意:session scope 的 bean 需要在 web 上下文中使用
|
||||
// 这里仅作演示,实际使用时通过方法参数获取
|
||||
|
||||
/**
|
||||
* 查看所有 Bean
|
||||
@@ -100,7 +99,7 @@ public class IocLearningController {
|
||||
"prototype", "原型 - 每次请求都创建新实例",
|
||||
"request", "请求 - 每个 HTTP 请求一个实例",
|
||||
"session", "会话 - 每个 HTTP 会话一个实例",
|
||||
"demo", learningBean.getInstanceInfo()
|
||||
"tip", "session scope 需要在 web 请求上下文中使用"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.scaffold.mapper;
|
||||
|
||||
import com.example.scaffold.entity.User;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.cache.decorators.LruCache;
|
||||
import org.apache.ibatis.cache.impl.PerpetualCache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
* 5. @CacheNamespace - 二级缓存
|
||||
*/
|
||||
@Mapper
|
||||
@CacheNamespace(implementation = LruCache.class, size = 1024)
|
||||
@CacheNamespace
|
||||
public interface UserMapper {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user