Spring boot AMQP and Spring Hadoop together ends up with missing EmbeddedServletContainerFactory bean -
i have 2 small apps, 1 uses spring-boot-starter-amqp
, other uses spring-data-hadoop-boot
. can run them separately without problems.
when join them together, app start fails exception: org.springframework.context.applicationcontextexception: unable start embeddedwebapplicationcontext due missing embeddedservletcontainerfactory bean
.
my main class pretty generic , works fine both of them separately:
@propertysource("file:conf/app.properties") @springbootapplication public class job { public static void main(string[] args) throws exception { springapplication.run(job.class, args); } }
i @ lost here. afaik @springbootapplication
contains annotations needed, including auto configuration , components scanning. i've had no need configure web environment not using it. why need when both dependencies in class path, , how fix it?
update
i dug little bit in spring boot code. main problem springapplication.deducewebenvironment()
automatically detects kind of environment should configured based on existence of classes in class path.
for web environment 2 classes being checked. when both of them in class path, web environment detected requires proper configuration, obviously.
javax.servlet.servlet
org.springframework.web.context.configurablewebapplicationcontext
spring-boot-starter-amqp:1.3.1.release
contains configurablewebapplicationcontext
, , spring-data-hadoop-boot:2.3.0.release-cdh5
contains servlet
(in native hadoop libs).
now, when run alone, 1 of above classes missing in both cases, results in web environment not being set.
but when use both of them - both classes can found. web environment detected, false positive, , requires configuration, not able (and don't want) provide.
so question - can force non web environment, when have classes in class path? or there other way solve issue? (other excluding them gradle dependencies)
solved.
following question: how prevent spring-boot autoconfiguration spring-web?
i run application follows.
@propertysource("file:conf/app.properties") @springbootapplication public class job { public static void main(string[] args) throws exception { new springapplicationbuilder(job.class).web(false).run(args); } }
answers above question suggested use property spring.main.web_environment=false
or annotation @enableautoconfiguration(exclude = webmvcautoconfiguration.class)
. both solutions haven't worked me. programmatic solution works in case.
Comments
Post a Comment