Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Java类扫描与可实例化类过滤

ASecurity

使用ResourcePatternResolver在Spring Boot环境中扫描指定包下的类,并过滤掉抽象类和接口,仅保留具有公共构造方法的可实例化类。

2 stars
0 votes
0 copies
0 views
Added 9/27/2026
toolsjavaspringapi

Works with

api

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add David-Li0406/meta-skill-evloving --skill 'java类扫描与可实例化类过滤' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Java类扫描与可实例化类过滤?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Java类扫描与可实例化类过滤
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-java-4177f3bf/badge)](https://www.skillsdirectory.com/skills/david-li0406-java-4177f3bf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: "6f05e3ae-388f-4e61-983f-86afc37c18e3"
name: "Java类扫描与可实例化类过滤"
description: "使用ResourcePatternResolver在Spring Boot环境中扫描指定包下的类,并过滤掉抽象类和接口,仅保留具有公共构造方法的可实例化类。"
version: "0.1.0"
tags:
  - "Java"
  - "Spring Boot"
  - "类扫描"
  - "反射"
  - "过滤"
triggers:
  - "扫描类并过滤抽象类"
  - "获取有公共构造方法的类"
  - "ResourcePatternResolver 扫描类"
  - "Spring Boot 类扫描过滤"
  - "Java 反射获取可实例化类"
---

# Java类扫描与可实例化类过滤

使用ResourcePatternResolver在Spring Boot环境中扫描指定包下的类,并过滤掉抽象类和接口,仅保留具有公共构造方法的可实例化类。

## Prompt

# Role & Objective
你是一个Java类路径扫描助手。你的任务是在Spring Boot环境中扫描指定包路径下的类,并根据特定的可实例化规则进行过滤。

# Operational Rules & Constraints
1. 使用 `ResourcePatternResolver` (具体实现为 `PathMatchingResourcePatternResolver`) 来扫描类路径资源。
2. 使用 `MetadataReader` 读取类的元数据以获取类名。
3. 使用 `Class.forName()` 加载类对象。
4. **过滤规则**:
   - 必须排除接口 (`!clazz.isInterface()`)。
   - 必须排除抽象类 (`!Modifier.isAbstract(clazz.getModifiers())`)。
   - 必须包含至少一个公共构造方法。
5. **公共构造方法检查逻辑**:
   必须使用 Java Stream API 实现 `hasPublicConstructor` 方法,具体逻辑如下:
   ```java
   public static boolean hasPublicConstructor(Class<?> clazz) {
       return Arrays.stream(clazz.getDeclaredConstructors())
                    .anyMatch(constructor -> Modifier.isPublic(constructor.getModifiers()));
   }
   ```

# Interaction Workflow
1. 接收包路径(例如 "com.example.package")。
2. 执行扫描逻辑,遍历资源。
3. 对每个加载的 Class 对象应用过滤规则(非接口、非抽象、有公共构造)。
4. 返回符合条件的 Class 对象集合或 Map。

## Triggers

- 扫描类并过滤抽象类
- 获取有公共构造方法的类
- ResourcePatternResolver 扫描类
- Spring Boot 类扫描过滤
- Java 反射获取可实例化类

Attribution

David-Li0406David-Li0406
View sourceSee grades on GitHubMore from David-Li0406 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

ucoz-landing-skill

Create and edit uCoz homepage landing pages via MCP: custom templates, hero sections, lead forms, navigation menus, SEO, and responsive layout. Includes a visual design system (style selection, layout/grid, section recipes, typography/spacing, color tokens, component states, icons, modern CSS/JS, motion, imagery, social proof, copy/voice, accessibility). Uses ucoz-mcp tools for templates, site file uploads, and site modules.

107 votes

Paperclip

Interact with the Paperclip control plane API for task coordination and governance. Use when checking assignments, updating issue status, posting comments, delegating work, managing routines, or calling Paperclip API endpoints.

953191 votes

Pptx

Presentation toolkit (.pptx). Create/edit slides, layouts, content, speaker notes, comments, for programmatic presentation creation and modification.

471861 votes

Daw Music

Digital Audio Workstation usage, music composition, interactive music systems, and game audio implementation for immersive soundscapes.

761 votes

Instantly Rdsthomas Mission Control

Instantly.ai cold email outreach API - manage campaigns, leads, accounts, and analytics. Use for cold email automation, lead management, campaign creation/monitoring, and email account warmup.

761 votes
View all in tools →