'Spring boot context in standalone application

I am writing plugin, which don't require to run main method, I want to use Spring-Context to have benefits of dependency injection.

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.3.16</version>
    </dependency>

I am sure that I am missing some part of configuration, but I couldn't find way how to configure spring context in my case. Test Service is null

"Main" class

    @Component
public final class GuildsFeatures extends JavaPlugin {


    @Autowired
    private TestService testService;



    @Override
    public void onEnable() {
        //testservice is null
        testService.test();
    }

    @Override
    public void onDisable() {

    }

}

Service class

@Service
public class TestService {

    public void test(){
        System.out.println("test");
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source