2011-05-04 6 views
13

우리는 Spring, Sping MVC 및 Hibernate를 사용하여 새로운 Java EE 웹 응용 프로그램을 시작합니다. 우리는 아마도 maven을 사용하고있을 것입니다.j2ee 웹 응용 프로그램의 표준 프로젝트/패키지 구조

시작하기 전에 웹 응용 프로그램의 프로젝트/패키지 구조를 생각해 내야합니다.

Java EE 웹 응용 프로그램의 표준 프로젝트/패키지 구조 란 무엇입니까?

또한 프로젝트 구조 또는 모든 구성 파일을 변경하지 않고 모든 응용 프로그램 서버에서 실행해야합니다.

우리는 스프링 소스 IDE 버전 2.6.0 (최신 릴리스)을 사용하게 될 것입니다.

아이디어가 있으십니까?

답변

21

maven을 사용하는 경우 표준 maven 프로젝트 레이아웃을 따르는 것이 가장 좋습니다. 당신은 선택

이 같은 당신에게 패키지 구조를 줄 것이다 목록에서 수행하여 당신을 위해이 구조를 생성하는

mvn archetype:generate 

선택 스프링 MVC-JPA-원형을 받는다는를 얻을 수 있습니다

├── pom.xml 
    └── src 
     ├── main 
     │   ├── java 
     │   │   └── mygroup 
     │   │    ├── controller 
     │   │    │   ├── HomeController.java 
     │   │    │   └── PersonController.java 
     │   │    ├── dao 
     │   │    │   └── PersonDao.java 
     │   │    └── model 
     │   │     └── Person.java 
     │   ├── resources 
     │   │   ├── db.properties 
     │   │   ├── log4j.xml 
     │   │   └── META-INF 
     │   │    └── persistence.xml 
     │   └── webapp 
     │    ├── index.html 
     │    ├── META-INF 
     │    │   ├── context.xml 
     │    │   └── MANIFEST.MF 
     │    ├── resources 
     │    │   └── css 
     │    │    └── screen.css 
     │    └── WEB-INF 
     │     ├── spring 
     │     │   ├── app 
     │     │   │   ├── controllers.xml 
     │     │   │   └── servlet-context.xml 
     │     │   ├── db.xml 
     │     │   └── root-context.xml 
     │     ├── views 
     │     │   ├── edit.jsp 
     │     │   ├── home.jsp 
     │     │   └── list.jsp 
     │     └── web.xml 
     └── test 
      ├── java 
      │   └── mygroup 
      │    ├── controller 
      │    │   ├── DataInitializer.java 
      │    │   ├── HomeControllerTest.java 
      │    │   └── PersonControllerTest.java 
      │    └── dao 
      │     └── PersonDaoTest.java 
      └── resources 
       ├── db.properties 
       ├── log4j.xml 
       ├── test-context.xml 
       └── test-db.xml 
+0

안녕하세요. 답장을 보내 주셔서 감사합니다. 나는 그것을 시도했지만 우리는 ejb의 기타 물건을 사용하지 않을 것이다. 이 외에도 스프링 컨트롤러, 모델, 서비스, 비즈니스 로직, 다양한 인터페이스 등 클래스를 구성하는 방법은 무엇입니까? – ashishjmeshram

+1

는 spring-mvc-jpa-archetype을 사용하는 나의 대답을 업데이트했습니다. – sbridges

11

MVCSR의 일반적인, 더 완전한 Java 패키지 구조 (모델, 뷰, 컨트롤러, 서비스, 저장소) 웹 응용 프로그램은 간다 뭔가 같은 :

java 
└── com 
    └── youdomain 
     | 
     ├── base // broadly used app-wide base and abstract classes) 
     | 
     ├── core // broadly, scattered use helpers, utilities, app health/stats 
     |   // tracking, logging, etc 
     | 
     ├── controller // Fields Http/CGI requests and drives/initiates request 
     |   // comprehension, validation, security checks, requesting 
     |   // operations by the Service module and invoking the View to 
     |   // generate a response. 
     | 
     ├── data // This is the lower level data infrastructure, with several 
     |   //packages under it for mappers, schema tables/enums, helpers, 
     |   // record location, id management, etc 
     | 
     ├── domain // app-wide exposed classes, managers, and interfaces to 
     |   // each persisted (usually DB) domain 'object'. Each 
     |   // object often correlates to one table row in you DB. 
     |   // Domain objects are mostly considered data, but have some fundamental 
     |   // record construction, validation, elaboration, and ancillary information 
     |   // functionality which is opaque to the rest of the application. 
     |   // For example: Customer, Account, Purchase, Inventory, 
     |   // Product, Sale, Return, SpecialOffer, FeedbackComment... 
     | 
     ├── repository // more complicated persisted objects, often structured 
     |  // to address certain efficiency or traversal needs, often each 
     |  // repository is underpinned by several records, tables, 
     |  // and even cross-DB structures. Example: 
     |  // -- OrderHistory, 
     |  // -- ProductsGlobalSearchIndex, 
     |  // -- CustomerSpecificProductMarketingSuggestionCorrelates 
     | 
     ├── service // The smarts of the whole application, performs macro, holoistic 
     |  // operations involving multiple DB tables and operations. Such as: 
     |  // -- account.UserAccountLifecycle, 
     |  // -- order.CustomerOrder, 
     |  // -- order.CustomerOrderShipment 
     | 
     └── view // Intefaces with your jsp, freemarker, tapestry etc. 
관련 문제