Hello,

I have a class with 3 autowired attributes but they are allways null (ctx, agreementConfig and agreementLAN). Sorry for the newbie question, but I am testing several options and they don't work. If you have suggestions, please let me know.

Main Class

Java Code:
    package com.prj.sc.tests;
    
    @ComponentScan("com.prj.sc.Agreement")
    @SpringBootApplication
    public class zt_Agreement {
    
    
        public static void main(String[] args) throws SignatureException, InterruptedException {
    
            try {
                ApplicationContext ctx = SpringApplication.run(zt_Agreement.class, args);
                Agreement oAgreement = new Agreement();

Service class with the autowired null objects (ctx, agreementConfig and agreementLAN)

Java Code:
    package com.prj.sc.Agreement;
    
    @Component
    public class Agreement {
    
        @Autowired
        public AgreementNetwork agreementConfig;
        @Autowired
        public AgreementLAN agreementLAN;
        @Autowired
        private ApplicationContext ctx;

        public Agreement() {
    
            System.out.println(agreementConfig.AgreementAddress());
            System.out.println(agreementLAN.mordenConfig().AgreementAddress());
The basis clases:

Java Code:
    package com.prj.sc.Agreement;
    
    @Service
    public class AgreementLAN {
    
        public AgreementLAN() {
    
        }
    
        public AgreementNetwork mordenConfig() {
            return new AgreementNetwork();
        }
    
    }
and

Java Code:
    package com.prj.sc.Agreement;
    
    
    @Component
    public class AgreementNetwork {
    
        public AgreementNetwork() {
        }
    
        public String AgreementAddress( ) {
    
            return "Mainstreet 22";
        }
    
    
    }
Suggestions are welcomed

Thanks a lot in advance
S.