@Springfield - Basic

Code

package com.u2ware.springfield.sample.part1.step3;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import com.u2ware.springfield.config.Springfield;
import com.u2ware.springfield.config.Springfield.Strategy;

@Springfield(
	strategy=Strategy.MONGODB
)
@Document
public @ToString class MongodbBean {

	@Id
	@Getter @Setter private String id;
	@Getter @Setter private String password;
	@Getter @Setter private String name;
	@Getter @Setter private Integer age;
}
		

Beans

@Springfield(strategy=Strategy.SQLSESSION) 선언으로 다음 4개의 Bean 이 자동 생성, 등록 된다.

bean name bean type bean implement
"mongodbBeanController"EntityController<MongodbBean, MongodbBean>com.u2ware.springfield.controller. EntityHandler
"mongodbBeanValidator" EntityValidator<MongodbBean, MongodbBean> com.u2ware.springfield.validation. EntityValidatorImpl
"mongodbBeanService" EntityService<MongodbBean, MongodbBean> com.u2ware.springfield.service. EntityServiceImpl
"mongodbBeanRepository"EntityRepository<MongodbBean, String>com.u2ware.springfield.repository.mongodb. EntityMongodbRepository

RequestMapping

CRUD 를 기본으로 한 EntityController 의 9 개 method 를 RequestMapping 한다.

매핑 경로 HTTP Method Controller Method 이름 예제 Command 객체 예제 매핑 경로
/{topLevelMapping}/ GET home() MongodbBean/part1/step3/
/{topLevelMapping} GET findForm() MongodbBean/part1/step3
/{topLevelMapping} POST find() MongodbBean/part1/step3
/{topLevelMapping}/{id} GET read() MongodbBean/part1/step3/baz
/{topLevelMapping}/new GET createForm()MongodbBean/part1/step3/new
/{topLevelMapping}/new POST create() MongodbBean/part1/step3/new
/{topLevelMapping}/{id}/editGET updateForm()MongodbBean/part1/step3/baz/eidt
/{topLevelMapping}/{id}/editPUT update() MongodbBean/part1/step3/baz/eidt
/{topLevelMapping}/{id}/editDELETEdelete() MongodbBean/part1/step3/baz/eidt
Note:
@Springfield 는 @org.springframework.data.annotation.Id 가 선언된 bean property 를 RequestMapping 의 {id}에 매핑한다.
Note:
@Springfield 의 topLevelMapping 속성에 별도의 선언 이 없으면, basePackage 를 기준으로 결정된다.
예제에서 basePackage 는 com.u2ware.springfield.sample 이므르 예제에서 topLevelMapping 은 /part1/step3 이 된다.

Mongodb

Reference
mongodb
spring-data-mongdb
application-context.properties:

mongodb 설정

orm.mongodb.host=localhost
orm.mongodb.port=27017