0

We want to run some remote tests in Docker. Our idea was to create a SpringBootApplication that will run the tests and report the results and we will have this Application deployed in it's own Docker with it's own JAR.

To make sure that it does not ship with the main code (src/main/java) we want to have this code in src/test/java..

From the documentation this does not appear possible from the Spring-boot-maven-plugin.

So now I am trying to create a test-jar but when I run the Application class I get

      .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                        

2019-01-24 10:38:56.736  INFO 5082 --- [           main] c.h.i.smoketest.SmokeTestApplication     : Starting SmokeTestApplication on 1usmfkelly.ad.here.com with PID 5082 (/usr/local/aaa/identity-client/target/identity-client-0.1.0-SNAPSHOT-tests.jar started by fkelly in /usr/local/aaa/identity-client/target)
2019-01-24 10:38:56.738  INFO 5082 --- [           main] c.h.i.smoketest.SmokeTestApplication     : No active profile set, falling back to default profiles: default
2019-01-24 10:38:56.777  INFO 5082 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3aeaafa6: startup date [Thu Jan 24 10:38:56 EST 2019]; root of context hierarchy
2019-01-24 10:38:56.852  WARN 5082 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.here.identity.smoketest.SmokeTestApplication]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
2019-01-24 10:38:56.860 ERROR 5082 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.here.identity.smoketest.SmokeTestApplication]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:558) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at com.here.identity.smoketest.SmokeTestApplication.main(SmokeTestApplication.java:12) [identity-client-0.1.0-SNAPSHOT-tests.jar:na]
Caused by: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
    at org.springframework.util.Assert.notEmpty(Assert.java:277) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:153) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:95) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:549) ~[identity-client-0.1.0-SNAPSHOT-jar-with-dependencies.jar:na]
    ... 14 common frames omitted

Is there any documentation on how to package a SpringBoot Application without the maven plugin?

kellyfj
  • 6,586
  • 12
  • 45
  • 66
  • package as in create the jar? you need some kind of compiler and you should use the default project structure since you don't seem to have any real reason not to. Why is shipping your application tied to your source code in anyway? – Will Evers Jan 24 '19 at 15:48

1 Answers1

0

It turns out all I needed to do as add a file to my source repo

src/main/resources/META-INF/spring.factories

You can grab a copy from here

All thanks to the answer from another post related the question

Praveen
  • 1,791
  • 3
  • 20
  • 33
kellyfj
  • 6,586
  • 12
  • 45
  • 66