java - SpringBoot helloworld MVC application won't load -
i'm familiar old way of using spring servlet mapping, thought i'd try springboot new application going quicker , use defaults wherever possible.
i can't seem basic helloworld controller work.
it seems springboot not bootstrapping @ all. put breakpoint in application main method , doesn't break.
using gradle build project, , deploy in tomcat through intellij.
i'm missing simple i'm sure. it?
here gradle file:
buildscript { ext { springbootversion = '1.2.3.release' } repositories { mavencentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springbootversion}") } } apply plugin: 'java' apply plugin: 'idea' apply plugin: 'spring-boot' apply plugin: 'war' war { basename = 'test' version = '0.0.1-snapshot' } sourcecompatibility = 1.8 targetcompatibility = 1.8 repositories { mavencentral() } configurations { providedruntime } dependencies { compile("org.springframework.boot:spring-boot-starter-actuator") compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.boot:spring-boot-starter-aop") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-log4j2") providedruntime("org.springframework.boot:spring-boot-starter-tomcat") testcompile("org.springframework.boot:spring-boot-starter-test") } task wrapper(type: wrapper) { gradleversion = '1.12' }
application.java
@springbootapplication public class testapplication { public static void main(string[] args) { applicationcontext ctx = springapplication.run(testapplication.class, args); } }
servlet initializer:
public class servletinitializer extends springbootservletinitializer { @override protected springapplicationbuilder configure(springapplicationbuilder application) { return application.sources(testapplication.class); } }
and controller:
@restcontroller @enableautoconfiguration public class indexcontroller { @requestmapping("/") public string index() { return "greetings spring boot!"; } }
found problem.
i started new application without spring boot. old fashioned xml based spring application, , approach see exception. complaining compiling in 1 java version , running in another. trying working in java 8.
i have switched java 7 , sure enough, springboot application works fine.
thanks paulinuk suggestion. it's not great can't see exceptions if there issue when bootstrapping springboot though.
Comments
Post a Comment