Annotation Interface Component


@Target(TYPE) @Retention(RUNTIME) public @interface Component
Marks a class as a component that can be auto-created by the dependency injection container.

Classes marked with this annotation will be automatically instantiated when requested, with their dependencies injected from the container. All components are singletons - only one instance is created and cached.

Dependencies are injected via constructor. The container supports Lombok's @RequiredArgsConstructor and @AllArgsConstructor.

Example usage:


 @Component
 public class PlayerDataManager {
   private final DatabaseConnection database;
   private final CacheService cache;

   // Dependencies auto-injected
   public PlayerDataManager(DatabaseConnection database, CacheService cache) {
     this.database = database;
     this.cache = cache;
   }
 }

 // With Lombok:
 @Component
 @RequiredArgsConstructor
 public class PlayerDataManager {
   private final DatabaseConnection database;
   private final CacheService cache;
 }