refactor: optimize string concatenation and add startup statistics
- Replace string concatenation with .formatted() method for better readability - Add StartupStatistics class to track initialization metrics - Add detailed startup logging with timing information - Scan time - IOC time - Injection time - PostConstruct time - Total startup time - Add banner output support (banner.txt or defBanner.txt) - Add @Lazy annotation support for lazy initialization Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,11 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 标记用于依赖注入的构造器
|
||||
* 标记用于依赖注入的构造器或字段
|
||||
*
|
||||
* @author 夜雨
|
||||
*/
|
||||
@Target(ElementType.CONSTRUCTOR)
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Inject {
|
||||
}
|
||||
|
||||
17
src/main/java/com/imyeyu/inject/annotation/Lazy.java
Normal file
17
src/main/java/com/imyeyu/inject/annotation/Lazy.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.imyeyu.inject.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 标记 Bean 为懒加载
|
||||
* 等同于 @Scope(value = ScopeType.SINGLETON, lazy = true)
|
||||
*
|
||||
* @author 夜雨
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Lazy {
|
||||
}
|
||||
@@ -18,4 +18,11 @@ public @interface Scope {
|
||||
* 作用域类型
|
||||
*/
|
||||
ScopeType value() default ScopeType.SINGLETON;
|
||||
|
||||
/**
|
||||
* 是否懒加载(仅对 SINGLETON 作用域有效)
|
||||
* true - 首次使用时才创建
|
||||
* false - 启动时立即创建(默认)
|
||||
*/
|
||||
boolean lazy() default false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user