Skip to content

Instantly share code, notes, and snippets.

View joshlong's full-sized avatar
🍃
i'm on Twitter @starbuxman

Josh Long joshlong

🍃
i'm on Twitter @starbuxman
View GitHub Profile
@joshlong
joshlong / gist:2478860
Created April 24, 2012 11:18
An Example demonstrating prototype injection. Each time the 'BeanThatDependsOnAnother' is used, it invokes a method on the 'Dependency' class, triggering the creation of a new bean, thanks to Spring's smart use of proxies
package org.springsource.examples.sawt.proxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.*;
public class Main {
@Configuration
@EnableAspectJAutoProxy
static class MyConfigurationClass {
@joshlong
joshlong / basic-springmvc-configuration
Created February 6, 2013 21:36
this demonstrates how to setup Spring MVC with the absolute basic minimum requirements using Spring MVC 3.1+-style java configuration
package org.springsource.examples.spring31.web.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
@Configuration
@EnableWebMvc
public class WebMvcConfiguration {
}
./pom.xml
./src
./src/main
./src/main/java
./src/main/resources
./src/test
./src/test/java
./src/test/resources
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ page session="false" %>
<!doctype html>
<html ng-app="crm">
<head>
<!-- ... -->
@Bean
public TilesConfigurer tilesConfigurer() {
TilesConfigurer tilesConfigurer = new TilesConfigurer();
tilesConfigurer.setDefinitions(new String[]{
"/WEB-INF/layouts/tiles.xml",
"/WEB-INF/views/**/tiles.xml"
});
return tilesConfigurer;
}
package org.springsource.examples.spring31.web.config;
// ...
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses = { ViewController.class, CustomerService.class })
public class WebMvcConfiguration {
package org.springsource.examples.spring31.web.config;
// ...
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses = { ViewController.class, CustomerService.class })
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
//...
package org.springsource.examples.spring31.web.config;
// ...
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses = { ViewController.class, CustomerService.class })
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
//...
package org.springsource.examples.spring31.web.config;
// ...
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses = { ViewController.class, CustomerService.class })
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
@Bean
<h1> Hello ${name} ! </h1>