百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

propify

> 编程语言
开源

一个轻量级的 Java 注解处理器,可从配置文件 (YAML/Properties) 生成类型安全的 Java 代码

198 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个轻量级的 Java 注解处理器,可从配置文件 (YAML/Properties) 生成类型安全的 Java 代码

Propify


Propify is a Java annotation processor that generates typed APIs from configuration files (YAML, INI, .properties), i18n bundles, and schema definitions (JSON Schema, OpenAPI).

If a config key, message key, or schema shape changes, the generated API changes with it and mismatches show up during compilation rather than as runtime lookups.

It supports nested properties, custom lookup providers (env/system/custom), ICU4J message formatting, and schema-based POJO generation. Generated code is regular Java; you call it from your application code.


Table of Contents

  1. Why Propify?
  2. Features
  3. Requirements
  4. Installation
  5. Quick Start
  6. Internationalization (i18n)
  7. Schema-Based Generation
  8. How It Works
  9. Examples
  10. Documentation
    • @Propify Guide - Complete guide to type-safe configuration
    • @I18n Guide - Comprehensive internationalization guide
    • @SchemaGen Guide - Schema-based POJO generation guide
  11. Getting Help
  12. Contributing
  13. License
  14. Acknowledgments

Why Propify?

  • Typed access: use generated getters/methods instead of config.get("a.b.c")-style lookups.
  • Earlier failures: missing keys and invalid formats fail the build, not production.
  • Less glue code: no hand-written parsing/mapping for common cases.
  • Extensible resolution: plug in custom lookup providers for env vars, system properties, or your own sources.

Features

  • Type-safe config: generate APIs from YAML, INI, or .properties.
  • Type-safe i18n: generate resource bundle accessors; ICU4J MessageFormat support.
  • Schema-based POJOs: generate mutable DTOs from JSON Schema or OpenAPI specs.
  • Compile-time validation: syntax and schema checks happen during the build.
  • Nested keys: hierarchical configs map to nested types.
  • Custom lookups: resolve values from env/system/custom providers.
  • Compile-time generation: no runtime parsing step required for the generated accessors.

Requirements

  • Java: 8 or higher
  • Build: Maven or Gradle

Installation

Maven

Add dependency and annotation processor:

xml

  
    com.vgerbot
    propify
    3.0.0
  

  
    
      maven-compiler-plugin
      3.8.1
      
        1.8
        1.8
        
          
            com.vgerbot
            propify
            3.0.0
          
        
      
    
  

Gradle (≥4.6)

groovy
dependencies {
  implementation 'com.vgerbot:propify:3.0.0'
  annotationProcessor 'com.vgerbot:propify:3.0.0'
}

Gradle ( For other tools, configure your build to include propify as an annotation processor.


Quick Start

  1. Create src/main/resources/application.yml:

    yaml
    server:
      host: localhost
      port: 8080
    database:
      url: jdbc:mysql://localhost:3306/mydb
      username: root
      password: secret
  2. Annotate an interface:

    java
    @Propify(location = "application.yml")
    public interface AppConfig {}
  3. Use the generated API:

    java
    public class Main {
      public static void main(String[] args) {
        AppConfigPropify cfg = AppConfigPropify.getInstance();
        System.out.println(cfg.getServer().getHost());
        System.out.println(cfg.getDatabase().getUrl());
      }
    }

Full @Propify Documentation - Learn about custom lookups, media types, advanced configuration options, and more.


Internationalization (i18n)

Generate type-safe resource bundles using ICU4J:

  1. Create message files in resources/:

    properties
    # messages.properties (default)
    welcome=Welcome
    greeting=Hello, {0}!
    
    # messages_zh_CN.properties
    welcome=欢迎
    greeting=你好, {0}!
  2. Annotate a class:

    java
    @I18n(baseName = "messages", defaultLocale = "en")
    public class Messages {}
  3. Access messages:

    java
    String hi = MessageResource.getDefault().greeting("Alice");
    String hiZh = MessageResource.get(Locale.CHINESE).greeting("张三");

Full @I18n Documentation - Explore ICU MessageFormat, pluralization, date/time formatting, and multi-locale support.


Schema-Based Generation

Generate mutable POJO/DTO classes from schema definitions for REST APIs and data modeling:

Quick Example

java
// 1. Create a JSON Schema or OpenAPI spec
@SchemaGen(location = "schemas/user.schema.json")
public interface UserSchema {}

// 2. Use the generated POJO
User user = User.builder()
    .username("johndoe")
    .email("[email protected]")
    .build();

// 3. Serialize/deserialize with Jackson
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(user);
User deserializedUser = mapper.readValue(json, User.class);

Key points:

  • Mutable POJOs with getters/setters
  • Builder pattern for fluent construction
  • Optional Jackson annotations for JSON serialization
  • Optional Bean Validation annotations (@NotNull, @Email, @Size, etc.)
  • JSON Schema and OpenAPI 3.x inputs

Full @SchemaGen Documentation - Learn about OpenAPI support, type mapping, validation annotations, and more.


How It Works

  1. Scan for @Propify, @I18n, and @SchemaGen annotations
  2. Parse configuration files, message bundles, and schema definitions
  3. Generate Java implementation classes and POJOs
  4. Compile everything together—fail-fast on errors

Examples

Check the example/ directory for complete working examples:

  • Basic Configuration - Simple YAML/Properties configuration
  • Advanced Configuration - Custom lookups and nested structures
  • INI Configuration - INI format support
  • Internationalization - Multi-locale messages with ICU formatting
  • Schema Generation - JSON Schema and OpenAPI POJO generation

Getting Help

If you encounter any issues or have questions about using Propify:

  • GitHub Issues: Submit a new issue on our GitHub repository
  • Documentation: Check the Wiki for detailed documentation
  • Examples: Browse the example directory for sample projects

Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/xyz)
  3. Implement and test your changes
  4. Submit a Pull Request

Please follow the existing coding style and update tests.


License

MIT © 2024 vgerbot-libraries


Acknowledgments

  • JavaPoet - Java source file generation
  • Jackson YAML - YAML parsing
  • Apache Commons Configuration - Configuration management
  • ICU4J - Internationalization support

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言