{"id":18477917,"url":"https://github.com/lets-mica/mica-auto","last_synced_at":"2025-05-16T07:05:05.093Z","repository":{"id":41271465,"uuid":"164529685","full_name":"lets-mica/mica-auto","owner":"lets-mica","description":"mica-auto 使用注解自动生成 java spi 和 Spring boot 的配置。🔝🔝 记得右上角点个star 关注更新！","archived":false,"fork":false,"pushed_at":"2024-11-06T03:47:07.000Z","size":518,"stargazers_count":198,"open_issues_count":1,"forks_count":48,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-08T16:09:46.895Z","etag":null,"topics":["java","java-spi","mica-auto","spring","spring-boot","spring-cloud"],"latest_commit_sha":null,"homepage":"https://www.dreamlu.net","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lets-mica.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-08T01:36:44.000Z","updated_at":"2025-04-03T06:56:23.000Z","dependencies_parsed_at":"2023-12-01T02:40:44.355Z","dependency_job_id":"19cc630c-e334-4510-8ef2-79cc779742ab","html_url":"https://github.com/lets-mica/mica-auto","commit_stats":{"total_commits":168,"total_committers":3,"mean_commits":56.0,"dds":0.07738095238095233,"last_synced_commit":"beb4287a73e82cb5e36a88c768e53cae7da946fe"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lets-mica%2Fmica-auto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lets-mica%2Fmica-auto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lets-mica%2Fmica-auto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lets-mica%2Fmica-auto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lets-mica","download_url":"https://codeload.github.com/lets-mica/mica-auto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485055,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","java-spi","mica-auto","spring","spring-boot","spring-cloud"],"created_at":"2024-11-06T12:07:53.182Z","updated_at":"2025-05-16T07:05:00.083Z","avatar_url":"https://github.com/lets-mica.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mica-auto SPI、Spring boot starter 利器\n[![Java CI](https://github.com/lets-mica/mica-auto/workflows/Java%20CI/badge.svg)](https://github.com/lets-mica/mica-auto/actions)\n![JAVA 8](https://img.shields.io/badge/JDK-1.8+-brightgreen.svg)\n[![mica-auto Maven](https://img.shields.io/maven-central/v/net.dreamlu/mica-auto.svg?style=flat-square)](https://central.sonatype.com/artifact/net.dreamlu/mica-auto/versions)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/681f9f08bc3d4b799f843eb2ff8be287)](https://www.codacy.com/gh/lets-mica/mica-auto/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=lets-mica/mica-auto\u0026amp;utm_campaign=Badge_Grade)\n\n`mica-auto` 是 `Spring cloud` 微服务框架 `Mica` 中的一个基础组件，用来生成 `Spring boot starter` 的一些基础配置。 \n\n[✨✨✨推广：**BladeX 物联网平台**✨✨✨iot.bladex.cn](https://iot.bladex.cn?from=mica-mqtt)\n\n------\n\n简体中文 | [English](README_EN.md) | [版本更新记录](CHANGELOG.md)\n\n## 版本说明\n| version | spring boot version | java version |\n|---------|---------------------|--------------|\n| 3.1.4   | 3.x                 | 17           |\n| 2.3.5   | 1.x ~ 3.x           | 1.8          |\n\n## 原理\n\nmica auto 采用 Annotation Processor，她不是什么新技术，在 jdk 1.6 就存在了。 Annotation Processor 是 javac 的一个工具，它用来在编译时扫描和处理注解。通过 Annotation Processor 可以获取到注解和被注解对象的相关信息，然后根据注解自动生成Java代码，省去了手动编写，提高了编码效率。大名鼎鼎的 Lombok 也是采用的该技术。\n\n## 使用场景\n主要是用来避免 Spring boot 主项目包同 `子项目`或者`子模块` 包不一致，避免包扫描不到的问题。 \n\n- 自定义 `spring boot starter`。\n- 多模块项目中的`子项目`（不建议主项目添加 `mica-auto`）。\n\n## 功能\n- 自动生成 spring.factories、spring-devtools.properties 配置（Spring boot starter 开发利器）。\n- 生成 FeignClient 到 spring.factories 中，供 mica-cloud 中完成 Feign 自动化配置。\n- 生成 java spi 配置，需要添加 `@AutoService` 注解。\n\n| 注解                            | spring.factories 或 Spi key     |\n| ------------------------------- | ------------------------------- |\n| @AutoContextInitializer         | ApplicationContextInitializer   |\n| @AutoListener                   | ApplicationListener             |\n| @AutoRunListener                | SpringApplicationRunListener    |\n| @AutoEnvPostProcessor           | EnvironmentPostProcessor        |\n| @AutoFailureAnalyzer            | FailureAnalyzer                 |\n| @AutoConfigImportFilter         | AutoConfigurationImportFilter   |\n| @AutoTemplateProvider           | TemplateAvailabilityProvider    |\n| @AutoEnableCircuitBreaker       | EnableCircuitBreaker            |\n| @AutoConfigDataLocationResolver | ConfigDataLocationResolver      |\n| @AutoConfigDataLoader           | ConfigDataLoader                |\n| @AutoDatabaseInitializerDetector | DatabaseInitializerDetector         |\n| @AutoDependsOnDatabaseInitializationDetector | DependsOnDatabaseInitializationDetector         |\n| @Component                      | EnableAutoConfiguration         |\n| @AutoIgnore                     | 忽略，不生成到 spring.factories |\n| @AutoService                    | java Spi 生成配置               |\n\n| 注解                            | aot.factories                     |\n| ------------------------------- | ------------------------------- |\n| @AotRuntimeHintsRegistrar      | RuntimeHintsRegistrar                |\n| @AotBeanRegistration           | BeanRegistrationAotProcessor                |\n| @AotBeanFactoryInitialization  | BeanFactoryInitializationAotProcessor                |\n\n## 使用\n`注意：` 如果你项目中使用了 `Lombok` 请将 `mica-auto` 的依赖放置到 `Lombok` 后面。\n\n### maven\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003enet.dreamlu\u003c/groupId\u003e\n  \u003cartifactId\u003emica-auto\u003c/artifactId\u003e\n  \u003cversion\u003e${mica-auto.version}\u003c/version\u003e\n  \u003cscope\u003eprovided\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### gradle \u003e= 5.x\n```groovy\nannotationProcessor(\"net.dreamlu:mica-auto:$micaAutoVersion}\")\n```\n\n### gradle \u003c 5.x\n```groovy\ncompileOnly \"net.dreamlu:mica-auto:$micaAutoVersion\"\n```\n\n## 原理\n扫描 `@Component`，自动生成相应的配置，支持组合注解。\n\n## mica 生态\n\n- mica (Spring cloud 微服务组件集): https://gitee.com/596392912/mica\n- mica-auto (Spring boot starter 利器): https://gitee.com/596392912/mica-auto\n- mica-weixin（jfinal weixin 的 spring boot starter）：https://gitee.com/596392912/mica-weixin\n- mica-mqtt（基于 t-io 实现的 mqtt组件）：https://gitee.com/596392912/mica-mqtt\n- Spring cloud 微服务 http2 方案（h2c）: https://gitee.com/596392912/spring-cloud-java11\n\n## 开源协议\nLGPL（[GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html)）\n\nLGPL是GPL的一个为主要为类库使用设计的开源协议。和GPL要求任何使用/修改/衍生之GPL类库的的软件必须采用GPL协议不同。LGPL允许商业软件通过类库引用(link)方式使用LGPL类库而不需要开源商业软件的代码。这使得采用LGPL协议的开源代码可以被商业软件作为类库引用并发布和销售。\n\n但是如果修改LGPL协议的代码或者衍生，则所有修改的代码，涉及修改部分的额外代码和衍生的代码都必须采用LGPL协议。因此LGPL协议的开源代码很适合作为第三方类库被商业软件引用，但不适合希望以LGPL协议代码为基础，通过修改和衍生的方式做二次开发的商业软件采用。\n\n## 用户权益\n* 允许以引入不改源码的形式免费用于学习、毕设、公司项目、私活等。\n* 特殊情况修改代码，但仍然想闭源需经过作者同意。\n* 参考请注明：参考 mica-auto: https://github.com/lets-mica/mica-auto\n\n## 参考\nGoogle Auto: https://github.com/google/auto\n\nSpring 5 - spring-context-indexer: https://github.com/spring-projects/spring-framework/tree/main/spring-context-indexer\n\n## 微信公众号\n\n![如梦技术](docs/dreamlu-weixin.jpg)\n\n**JAVA架构日记**，精彩内容每日推荐！","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flets-mica%2Fmica-auto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flets-mica%2Fmica-auto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flets-mica%2Fmica-auto/lists"}