Java EE, Spring 및 Maven (Nexus 저장소 관리자 사용)을 사용하여 Eclipse에서 샘플 동적 웹 프로젝트를 설정하려고합니다. 필자는 이클립스에서 엔터프라이즈 웹 애플리케이션 용으로 설정해야하는 "모범 사례"디렉토리 구조를 아는 사람이 있는지 궁금하다. 나에게 기본 구조 만 고수해야 하는가? 내가 인터넷 (예를 들어, WEB-INF 및 META-INF 폴더가 어디에 있는지는 'war'디렉토리 등이 있습니다.)과 관련된 다양한 변형을 보았 기 때문에 묻습니다. 감사! their convention을 따라Java EE Eclipse 프로젝트 디렉토리 구조?
5
A
답변
2
당신은 메이븐을 사용하는 경우, 그것은 가장 좋습니다. 당신은 스프링을 사용하는 경우
, 당신은 EAR 필요하지 않습니다. WAR는 정상적으로 작동합니다.
WAR 파일에는 반드시 따라야 할 확실한 표준이 있습니다. 적절한 WAR 파일을 생성 할 수있는 한 소스 코드에 적합한 모든 디렉토리 구조를 사용할 수 있습니다.
나는 이런 식으로 뭔가를 사용 : 나는 인 IntelliJ를 사용
/project
+---/src (.java)
+---/test (TestNG .java here)
+---/test-lib (testNG JAR, Spring test JAR, etc.)
+---/resources (log4j.xml, etc.)
+---/web (root of web content here)
+---+---/WEB-INF
+---+---+---/classes (compile .java to this directory)
+---+---+---/lib (JAR files)
를, 그래서 나를 위해 출력으로 분해 WAR 파일을 만듭니다.
나는 일반적으로 IntelliJ에 디렉토리 구조를 다음과 개미의 build.xml 있습니다. 도움이된다면 침대에 오신 것을 환영합니다. 당신은 메이븐을 사용하는 경우<?xml version="1.0" encoding="UTF-8"?>
<project name="xslt-converter" basedir="." default="package">
<property name="version" value="1.6"/>
<property name="haltonfailure" value="no"/>
<property name="out" value="out"/>
<property name="production.src" value="src"/>
<property name="production.lib" value="lib"/>
<property name="production.resources" value="config"/>
<property name="production.classes" value="${out}/production/${ant.project.name}"/>
<property name="test.src" value="test"/>
<property name="test.lib" value="lib"/>
<property name="test.resources" value="config"/>
<property name="test.classes" value="${out}/test/${ant.project.name}"/>
<property name="exploded" value="out/exploded/${ant.project.name}"/>
<property name="exploded.classes" value="${exploded}/WEB-INF/classes"/>
<property name="exploded.lib" value="${exploded}/WEB-INF/lib"/>
<property name="reports.out" value="${out}/reports"/>
<property name="junit.out" value="${reports.out}/junit"/>
<property name="testng.out" value="${reports.out}/testng"/>
<path id="production.class.path">
<pathelement location="${production.classes}"/>
<pathelement location="${production.resources}"/>
<fileset dir="${production.lib}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*test*.jar"/>
</fileset>
</path>
<path id="test.class.path">
<path refid="production.class.path"/>
<pathelement location="${test.classes}"/>
<pathelement location="${test.resources}"/>
<fileset dir="${test.lib}">
<include name="**/junit*.jar"/>
<include name="**/*test*.jar"/>
</fileset>
</path>
<path id="testng.class.path">
<fileset dir="${test.lib}">
<include name="**/testng*.jar"/>
</fileset>
</path>
<available file="${out}" property="outputExists"/>
<target name="clean" description="remove all generated artifacts" if="outputExists">
<delete dir="${out}" includeEmptyDirs="true"/>
<delete dir="${reports.out}" includeEmptyDirs="true"/>
</target>
<target name="create" description="create the output directories" unless="outputExists">
<mkdir dir="${production.classes}"/>
<mkdir dir="${test.classes}"/>
<mkdir dir="${reports.out}"/>
<mkdir dir="${junit.out}"/>
<mkdir dir="${testng.out}"/>
<mkdir dir="${exploded.classes}"/>
<mkdir dir="${exploded.lib}"/>
</target>
<target name="compile" description="compile all .java source files" depends="create">
<!-- Debug output
<property name="production.class.path" refid="production.class.path"/>
<echo message="${production.class.path}"/>
-->
<javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}">
<classpath refid="production.class.path"/>
<include name="**/*.java"/>
<exclude name="**/*Test.java"/>
</javac>
<javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}">
<classpath refid="test.class.path"/>
<include name="**/*Test.java"/>
</javac>
</target>
<target name="junit-test" description="run all junit tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<junit printsummary="yes" haltonfailure="${haltonfailure}">
<classpath refid="test.class.path"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.out}">
<fileset dir="${test.src}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.out}">
<fileset dir="${junit.out}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${junit.out}" format="frames"/>
</junitreport>
</target>
<taskdef resource="testngtasks" classpathref="testng.class.path"/>
<target name="testng-test" description="run all testng tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50">
<classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/>
</testng>
</target>
<target name="exploded" description="create exploded deployment" depends="testng-test">
<copy todir="${exploded.classes}">
<fileset dir="${production.classes}"/>
</copy>
<copy todir="${exploded.lib}">
<fileset dir="${production.lib}"/>
</copy>
</target>
<target name="package" description="create package file" depends="exploded">
<jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/>
</target>
</project>
6
, 내가 따뜻하게 단지 Maven의 컨벤션을 따르도록 권하고 싶습니다. 이것은 Maven의 세계에서 "우수 사례"입니다. (그렇게하지 않을 이유가별로 없으며,이 조언을 따르지 않으면 더 많은 작업을 할 수 있습니다.)
웹 애플리케이션 프로젝트를 만들 수있는 쉬운 방법 중 하나는 받는다는 - 원형 - 웹 애플리케이션 사용하는 것입니다:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=com.mycompany.app \
-DartifactId=my-webapp \
-Dversion=1.0-SNAPSHOT
이 (당신은 리눅스 쉘에서 "있는 그대로"이 명령을 붙여 넣을 수 있습니다를, 모든 것을 입력 한 Windows에서 .
my-webapp
|-- pom.xml
`-- src
`-- main
|-- resources
`-- webapp
|-- WEB-INF
| `-- web.xml
`-- index.jsp
이 레이아웃은 당신이저기서하든 플러그인 이클립스 WTP (준수하십시오 "\"
없이 단일 선)
는 그리고 이것은 당신이 얻을 것이다 구조입니다 g Eclipse 통합 용). 이 프로젝트를 이클립스로 가져 오면 끝이다.
더 구체적인 질문이 있으시면 (예를 들어, 대부분 META-INF
디렉토리에 대해 걱정할 필요가 없지만 실제로 필요한 경우 src/main/resources
아래에 넣으십시오).
관련 문제
- 1. Eclipse Java EE 플러그인
- 2. Java EE 예제 프로젝트
- 3. STS/Eclipse "Java EE"퍼스펙티브가 Maven 디렉토리 구조를 인식하지 못합니다.
- 4. Java EE 프로젝트 비용 방법
- 5. Weblogic에 Java EE 프로젝트 배포
- 6. Eclipse EE - Java EE Perspective 대 Java Perspective
- 7. Java EE 디자인 패턴을 사용하는 Java EE 프로젝트 샘플.
- 8. Eclipse에서 Java 웹 애플리케이션의 구조
- 9. 타사 구성 요소가있는 프로젝트 디렉토리 구조
- 10. Django 프로젝트 구조 및 js 디렉토리 호출?
- 11. Java ee 및 Eclipse 튜토리얼을 도와주세요
- 12. Eclipse 용 Java EE 플러그인 3.4
- 13. Java EE 웹 프로젝트 및 문자 인코딩
- 14. Java EE 프로젝트, 너무 많은 메모리가 있습니까?
- 15. Eclipse CDT - 프로젝트 내 하위 디렉토리 빌드
- 16. Java EE 응용 프로그램 디렉토리 모범 사례 질문
- 17. Eclipse for Java (EE) 개발자와 Eclipse Classic의 차이점은 무엇입니까?
- 18. 명령이있는 디렉토리 구조.
- 19. 유닛 테스트 디렉토리 구조
- 20. Java EE 5와 Java EE 6의 차이점
- 21. Eclipse - 전체 디렉토리 무시
- 22. 전체 디렉토리 구조 포함하기
- 23. 패키지 구조 및 디렉토리 구조
- 24. Eclipse Java EE - Galileo - 플러그인을 볼 수 없습니다.
- 25. Eclipse 논리 디렉토리 그룹화
- 26. Java EE 및 JDK
- 27. Eclipse CDT 프로젝트 이해
- 28. Grails 프로젝트 구조 개요
- 29. Maven을 사용하여 eclipse groovy-java 프로젝트 만들기
- 30. Eclipse Java 프로젝트 사이에 참조 추가하기
Eclipse를 만들려면 및 받는다는 더 나은 플레이 내가 m2eclipse에 플러그인을 다운로드 좋을 것, 그것의 업데이트 사이트는 http://m2eclipse.sonatype.org/update/ 응답에 대한 –