Spring-Boot / Groovy / MVC “Hello World” example
The complete project can be found here: https://github.com/mtrojahn/spring-boot-groovy-mvc-simple This is yet another very basic example. This time I’ll show how to create get a Web-MVC Spring-Boot project started. You will notice I take the no-XML approach and I’ll try to keep my examples as XML-free as they can be because it’s hard to find fresh documentation about it on the Web. So, let me start with the build.gradle file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
group 'com.mtrojahn' version '1.0-SNAPSHOT' buildscript { repositories { mavenCentral() } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE" } } apply plugin: 'groovy' apply plugin: 'spring-boot' repositories { mavenCentral() } sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { compile "org.springframework.boot:spring-boot-starter-web" compile 'org.codehaus.groovy:groovy-all' testCompile "junit:junit" } bootRun { addResources = true } |
As you can see, no big changes from my previous example. Basically all you have to do is change spring-boot-starter to spring-boot-starter-web. Ok, now let’s have a look on the...