Runs a Spring Boot verification loop including build, static analysis, tests with coverage, security scanning, and diff review before PR or release.
How this skill is triggered — by the user, by Claude, or both
Slash command
/everything-claude-code:springboot-verificationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
在 PR 之前、重大更改之后和部署前运行。
在 PR 之前、重大更改之后和部署前运行。
mvn -T 4 clean verify -DskipTests
# 或
./gradlew clean assemble -x test
如果构建失败,停止并修复。
Maven(常用插件):
mvn -T 4 spotbugs:check pmd:check checkstyle:check
Gradle(如果已配置):
./gradlew checkstyleMain pmdMain spotbugsMain
mvn -T 4 test
mvn jacoco:report # 验证 80%+ 覆盖率
# 或
./gradlew test jacocoTestReport
报告:
使用模拟依赖隔离测试服务逻辑:
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
@Mock private UserRepository userRepository;
@InjectMocks private UserService userService;
@Test
void createUser_validInput_returnsUser() {
var dto = new CreateUserDto("Alice", "[email protected]");
var expected = new User(1L, "Alice", "[email protected]");
when(userRepository.save(any(User.class))).thenReturn(expected);
var result = userService.create(dto);
assertThat(result.name()).isEqualTo("Alice");
verify(userRepository).save(any(User.class));
}
@Test
void createUser_duplicateEmail_throwsException() {
var dto = new CreateUserDto("Alice", "[email protected]");
when(userRepository.existsByEmail(dto.email())).thenReturn(true);
assertThatThrownBy(() -> userService.create(dto))
.isInstanceOf(DuplicateEmailException.class);
}
}
使用真实数据库而非 H2:
@SpringBootTest
@Testcontainers
class UserRepositoryIntegrationTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine")
.withDatabaseName("testdb");
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
}
@Autowired private UserRepository userRepository;
@Test
void findByEmail_existingUser_returnsUser() {
userRepository.save(new User("Alice", "[email protected]"));
var found = userRepository.findByEmail("[email protected]");
assertThat(found).isPresent();
assertThat(found.get().getName()).isEqualTo("Alice");
}
}
使用完整 Spring 上下文测试控制器层:
@WebMvcTest(UserController.class)
class UserControllerTest {
@Autowired private MockMvc mockMvc;
@MockBean private UserService userService;
@Test
void createUser_validInput_returns201() throws Exception {
var user = new UserDto(1L, "Alice", "[email protected]");
when(userService.create(any())).thenReturn(user);
mockMvc.perform(post("/api/users")
.contentType(MediaType.APPLICATION_JSON)
.content("""
{"name": "Alice", "email": "[email protected]"}
"""))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.name").value("Alice"));
}
@Test
void createUser_invalidEmail_returns400() throws Exception {
mockMvc.perform(post("/api/users")
.contentType(MediaType.APPLICATION_JSON)
.content("""
{"name": "Alice", "email": "not-an-email"}
"""))
.andExpect(status().isBadRequest());
}
}
# 依赖 CVE 检查
mvn org.owasp:dependency-check-maven:check
# 或
./gradlew dependencyCheckAnalyze
# 源代码中的密钥
grep -rn "password\s*=\s*\"" src/ --include="*.java" --include="*.yml" --include="*.properties"
grep -rn "sk-\|api_key\|secret" src/ --include="*.java" --include="*.yml"
# 密钥(git 历史)
git secrets --scan # 如果已配置
# 检查 System.out.println(改用 logger)
grep -rn "System\.out\.print" src/main/ --include="*.java"
# 检查响应中的原始异常消息
grep -rn "e\.getMessage()" src/main/ --include="*.java"
# 检查通配符 CORS
grep -rn "allowedOrigins.*\*" src/main/ --include="*.java"
mvn spotless:apply # 如果使用 Spotless 插件
./gradlew spotlessApply
git diff --stat
git diff
检查清单:
System.out、没有守卫的 log.debug)验证报告
===================
构建: [通过/失败]
静态分析: [通过/失败](spotbugs/pmd/checkstyle)
测试: [通过/失败](X/Y 通过,Z% 覆盖率)
安全: [通过/失败](CVE 发现:N)
差异: [X 个文件变更]
总体: [就绪 / 未就绪]
待修复问题:
1. ...
2. ...
mvn -T 4 test + spotbugs 用于快速反馈记住:快速反馈胜过延迟意外。保持门控严格 — 在生产系统中将警告视为缺陷。
npx claudepluginhub aaione/everything-claude-code-zhExecutes Spring Boot verification loop: build, static analysis, tests with 80%+ coverage, security scans before PRs or deployments.
Runs a verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before PRs or releases.
Verifies Spring Boot 4.x projects for dependency compatibility, configuration correctness, and migration readiness. Analyzes pom.xml, build.gradle, and application.yml files.