configuration - how to disable http server in spring boot? -
spring boot documentation claims setting server.port=-1 disables http endpoint, me behaves same if used port=0. want achieve batch spring boot application starts, things , shuts down. right sits there until kill it.
how prevent starting http server? or instead - how shutdown spring boot application gracefully code?
i'm using version 1.2.4.release. have following annotations on main class:
@configuration @componentscan @enableautoconfiguration @enablecaching
edit - dependencies:
compile( 'redis.clients:sharded-jedis-sentinel-pool:0.2.10.08e7bbe', 'org.springframework.boot:spring-boot-starter-jdbc', 'org.springframework.boot:spring-boot-starter-web', 'mysql:mysql-connector-java:5.1.33', 'org.flywaydb:flyway-core:3.2.1', )
without spring-boot-starter-web spring throws:
exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.boot.autoconfigure.web.gzipfilterautoconfiguration': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.springframework.boot.autoconfigure.web.gzipfilterproperties org.springframework.boot.autoconfigure.web.gzipfilterautoconfiguration.properties; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'spring.http.gzip.configuration_properties': initialization of bean failed; nested exception java.lang.typenotpresentexception: type org.springframework.http.httpmethod not present @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:334) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1210) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:303) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:299) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:755) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:757) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:480) @ org.springframework.boot.springapplication.refresh(springapplication.java:686) @ org.springframework.boot.springapplication.run(springapplication.java:320) @ org.springframework.boot.springapplication.run(springapplication.java:957) @ org.springframework.boot.springapplication.run(springapplication.java:946) @ my.application.main(application.java:19) caused by: org.springframework.beans.factory.beancreationexception: not autowire field: private org.springframework.boot.autoconfigure.web.gzipfilterproperties org.springframework.boot.autoconfigure.web.gzipfilterautoconfiguration.properties; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'spring.http.gzip.configuration_properties': initialization of bean failed; nested exception java.lang.typenotpresentexception: type org.springframework.http.httpmethod not present @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:561) @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:88) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:331) ... 15 more caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'spring.http.gzip.configuration_properties': initialization of bean failed; nested exception java.lang.typenotpresentexception: type org.springframework.http.httpmethod not present @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:547) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:303) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:299) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.findautowirecandidates(defaultlistablebeanfactory.java:1120) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:1044) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:942) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:533) ... 17 more caused by: java.lang.typenotpresentexception: type org.springframework.http.httpmethod not present @ sun.reflect.generics.factory.corereflectionfactory.makenamedtype(corereflectionfactory.java:117) @ sun.reflect.generics.visitor.reifier.visitclasstypesignature(reifier.java:125) @ sun.reflect.generics.tree.classtypesignature.accept(classtypesignature.java:49) @ sun.reflect.generics.visitor.reifier.reifytypearguments(reifier.java:68) @ sun.reflect.generics.visitor.reifier.visitclasstypesignature(reifier.java:138) @ sun.reflect.generics.tree.classtypesignature.accept(classtypesignature.java:49) @ sun.reflect.generics.repository.constructorrepository.getparametertypes(constructorrepository.java:94) @ java.lang.reflect.executable.getgenericparametertypes(executable.java:279) @ java.lang.reflect.method.getgenericparametertypes(method.java:268) @ java.beans.featuredescriptor.getparametertypes(featuredescriptor.java:387) @ java.beans.methoddescriptor.setmethod(methoddescriptor.java:116) @ java.beans.methoddescriptor.<init>(methoddescriptor.java:72) @ java.beans.methoddescriptor.<init>(methoddescriptor.java:56) @ java.beans.introspector.gettargetmethodinfo(introspector.java:1163) @ java.beans.introspector.getbeaninfo(introspector.java:426) @ java.beans.introspector.getbeaninfo(introspector.java:173) @ org.springframework.beans.cachedintrospectionresults.<init>(cachedintrospectionresults.java:279) @ org.springframework.beans.cachedintrospectionresults.forclass(cachedintrospectionresults.java:189) @ org.springframework.beans.beanwrapperimpl.getcachedintrospectionresults(beanwrapperimpl.java:328) @ org.springframework.beans.beanwrapperimpl.getpropertydescriptors(beanwrapperimpl.java:336) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.filterpropertydescriptorsfordependencycheck(abstractautowirecapablebeanfactory.java:1364) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.filterpropertydescriptorsfordependencycheck(abstractautowirecapablebeanfactory.java:1343) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1205) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) ... 26 more caused by: java.lang.classnotfoundexception: org.springframework.http.httpmethod @ java.net.urlclassloader$1.run(urlclassloader.java:372) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:360) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:344) @ sun.reflect.generics.factory.corereflectionfactory.makenamedtype(corereflectionfactory.java:114) ... 49 more
to disable web environment, add line application.properties file:
spring.main.web-environment=false
Comments
Post a Comment