Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/spring-boot-farm/spring-boot-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ farm {
webapp project
webapp ':spring-boot-farm:spring-boot-webservice'
webapp ':spring-boot-farm:jee-webservice'
webapp ':spring-boot-farm:spring-web-mvc-webservice'
}

ext {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
apply from: rootProject.file('integrationTests.gradle')

dependencies {
compile "org.springframework:spring-webmvc:4.1.2.RELEASE"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.akhikhl.examples.gretty.springmvcapp;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class MyMvcController {
@RequestMapping(method = RequestMethod.GET)
public String test() {
return "MVC TEST";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.akhikhl.examples.gretty.springmvcapp;

import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) {
WebApplicationContext appContext = getContext();

ServletRegistration.Dynamic dispatcher = container.addServlet(
"dispatcher", new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}

private AnnotationConfigWebApplicationContext getContext() {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("org.akhikhl.examples.gretty.springmvcapp");
return context;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.akhikhl.examples.gretty.springmvcapp;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@EnableWebMvc
@Configuration
@ComponentScan(basePackages = "org.akhikhl.examples.gretty.springmvcapp")
public class WebConfig extends WebMvcConfigurerAdapter {
}