java - Spring application with embedded servlet container run error -


i learning spring , have problem. have created standalone application (web service) run in embedded servlet container. use intellij idea gradle. when run application idea - work fine. when have created jar file , run via console ("java -jar my.jar") have got error (below). load official sample (https://github.com/spring-guides/gs-rest-service) , it's not work (via running jar). see link not helped me: spring boot: unable start embeddedwebapplicationcontext due missing embeddedservletcontainerfactory bean

please help

error log:

18:47:26.079 [main] error o.s.boot.springapplication - application startup faile d org.springframework.context.applicationcontextexception: unable start embedde d container; nested exception org.springframework.context.applicationcontexte xception: unable start embeddedwebapplicationcontext due missing embeddeds ervletcontainerfactory bean.         @ org.springframework.boot.context.embedded.embeddedwebapplicationconte xt.onrefresh(embeddedwebapplicationcontext.java:135) ~[clientsim.jar:na]         @ org.springframework.context.support.abstractapplicationcontext.refres h(abstractapplicationcontext.java:476) ~[clientsim.jar:na]         @ org.springframework.boot.context.embedded.embeddedwebapplicationconte xt.refresh(embeddedwebapplicationcontext.java:120) ~[clientsim.jar:na]         @ org.springframework.boot.springapplication.refresh(springapplication. java:691) [clientsim.jar:na]         @ org.springframework.boot.springapplication.run(springapplication.java :320) [clientsim.jar:na]         @ org.springframework.boot.springapplication.run(springapplication.java :952) [clientsim.jar:na]         @ com.clientsim.server.application.main(application.java:13) [clientsim .jar:na] caused by: org.springframework.context.applicationcontextexception: unable st art embeddedwebapplicationcontext due missing embeddedservletcontainerfactory  bean. 

my build.gradle:

group 'clientsim' version '1.0-snapshot'  buildscript {     repositories {         maven { url "http://repo.spring.io/libs-release" }         mavenlocal()         mavencentral()     }     dependencies {         classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.release")     } }  apply plugin: 'java' apply plugin: 'idea' apply plugin: 'spring-boot'  sourcecompatibility = 1.5  repositories {     maven { url "http://repo.spring.io/libs-release" }     mavenlocal()     mavencentral() }  dependencies {     compile("org.springframework.boot:spring-boot-starter-web")     testcompile group: 'junit', name: 'junit', version: '4.11' } 

something tells me did not create jar using gradle ? perhaps exported intellij ?

(1) build gradle:

you should build jar using gradle (to create jar using spring-boot-gradle-plugin). open terminal @ root of project , type:

$ gradle build   ...  $ cd build/libs $ java -jar yourjar.jar 

(2) export spring-boot jar intellij:


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -