package example.u2ware.springfield.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 private @Getter @Setter Integer id; private @Getter @Setter String password; private @Getter @Setter String name; private @Getter @Setter String address; }
@Springfield(strategy=Strategy.MONGODB) 선언으로 다음 3개의 Bean 이 자동 생성, 등록 된다.
bean id | bean type | implements |
"mongodbBeanController" | EntityController<MongodbBean, MongodbBean> | com.u2ware.springfield.controller. EntityHandler |
"mongodbBeanService" | EntityService<MongodbBean, MongodbBean> | com.u2ware.springfield.service. EntityServiceImpl |
"mongodbBeanRepository" | EntityRepository<MongodbBean, Integer> | com.u2ware.springfield.repository.mongodb. EntityMongodbRepository |
orm.mongodb.host=localhost
orm.mongodb.port=27017
EntityController 는 CRUD 를 기본으로 한 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/7 |
/{topLevelMapping}/new | GET | createForm | MongodbBean | /part1/step3/new |
/{topLevelMapping}/new | POST | create | MongodbBean | /part1/step3/new |
/{topLevelMapping}/{id}/edit | GET | updateForm | MongodbBean | /part1/step3/7/eidt |
/{topLevelMapping}/{id}/edit | PUT | update | MongodbBean | /part1/step3/7/eidt |
/{topLevelMapping}/{id}/edit | DELETE | delete | MongodbBean | /part1/step3/7/eidt |