mardi 25 février 2020

How to resolve configuration in Spring 4.0.6 with multiple modules

I don't know how to explain correctly, so if I give not much information please tell me. I have a Spring project with multiple modules. When I try to create an integration test in the module "B", on my machine it runs but tomcat on the server is failed with Caused by: java.lang.IllegalArgumentException: Invalid boolean value [${general.Mail.bUseSSL}]

But these values from exception and properties are located in the module "A". I understand that is caused due to not correctly configure ApplicationContext, but I don't know how to fix it. The project works fine without tests. Moreover, integration tests in the module "A" also run fine.

I must admit, that I don't have much knowledge of configuration the Spring 4 with web.xml and etc. (I started to learn Spring just from Spring Boot, so please don't blame me).

Test example (I've written it just for test working):

@ActiveProfiles("default")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ApplicationConfiguration.class})
public class ActionEventEnforcementServiceTest {


    @Autowired
    ActionEventEnforcementController actionEventEnforcementController;



    @Test
    public void listShouldNotBeAnEmpty() {
        List<EnforcementInfoDerivedResponse> enforcementInfoDerived = actionEventEnforcementController.getEnforcementInfoDerived(9129688L);
        for(EnforcementInfoDerivedResponse response : enforcementInfoDerived) {
            System.out.println(response);
            log.info(response.toString());
        }
    }
}

ApplicationConfiguration (context.xml is located in the module "A"):

@Configuration
@ImportResource({"classpath:context.xml"})
public class ApplicationConfiguration {

}

Aucun commentaire:

Enregistrer un commentaire