(spring) Spring 환경세팅
1. 이클립스 세팅
- 프로젝트를 하나로 반디집으로 압축해서 관리
2. putty
- www.skysky.xyz
3. WAS
톰켓은 동접 5000명까지 가능
4. ojdbc 각 버전별 특징
- jdk 버전 별로 ojdbc 버전을 맞춰줘야 한다.
ojdbc13 = jdk1.3 ojdbc14 = jdk1.4 ojdbc5 = jdk1.5 ojdbc6 = jdk1.6
5. 프로젝트 폴더구조
1) maven 폴더
- settings.xml에 메이븐 다운로드 위치를 바꿔줘야함.
- 안그러면 user/m2 에 있는 repository에 디폴트로 생성된다. ~~~xml
## 6. 여러 유용한 eclipse plugin
1. AnyEdit - 단축키로 카멜케이스나, 변수이름을 단축키로 바꿔줌
## 7. url구조를 바꿔주는 것
1. hosts파일 세팅을 바꿔줘야함( 호스트 경로 = C:\Windows\System32\drivers\etc)
2. localhost 세팅을 바꿔줄 수 있다.
localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 www.xxx.com
## 8. pom.xml 설정
alt + f5를 사용해서 maven 업데이트를 해주어야 한다.
- 버전 바꾸기
~~~xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java-version>1.8</java-version>
<org.springframework-version>4.3.18.RELEASE</org.springframework-version>
<org.aspectj-version>1.9.1</org.aspectj-version>
<org.slf4j-version>1.7.25</org.slf4j-version>
<spring-security.version>4.2.7.RELEASE</spring-security.version>
<org.apache.tiles-version>3.0.8</org.apache.tiles-version>
</properties>
- 버전에 맞는 plugin 세팅
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<encoding>UTF-8</encoding>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
<!-- JavaDoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</build>
9. web.xml 설정
context-param, servlet 를 실행할 떄 읽어옴
- web.xml 설정 바꾸기
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/spring/com/**/context-*.xml</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/*-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>//*</url-pattern>
</servlet-mapping>
10. context.xml 수정
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
<context:component-scan base-package="kr.co.sinsp">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0" />
<bean id="JSON_VIEW" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="contentType" value="application/json;charset=UTF-8" />
</bean>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="1"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/views/"
p:suffix=".jsp">
</bean>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" p:order="2" />
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
<!-- spring 파비콘 적용법 -->
<!-- <mvc:resources mapping="/favicon.ico" location="/favicon.ico" /> -->
</beans>
11. context-common.xml 추가
- /src/main/resources/ : 패키지에
- config/spring/com/: 폴더경로 생성
- context-common.xml : xml 파일 생성
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 등록해야 할 Bean 클래스를 scan해서 대상이 되는 클래스를 자동으로 Spring Bean으로 등록하는 <context:component-scan> 태그 -->
<!-- context:exclude-filter 빈으로 등록을 안하겠다는 선언 -->
<context:component-scan base-package="kr.co.sinsp">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
## 폴더구조
webapp 직접 접근가능
WEB-INF 컨트롤러를 통해 접근 가능
댓글남기기