Post List

Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Friday, July 29, 2016

2. Spring MVC - Hello World example




1. Create a Maven Project

- File > New > Maven Project
- Select maven-archetype-webapp
- Enter an groupId and artifactId

ex) groupId : com.yunjee.springmvc / artifactId : SpringWeb

- Guide to naming
  https://maven.apache.org/guides/mini/guide-naming-conventions.html



2. Modify pom.xml

 Change pom.xml file to be the following :


3. Create web.xml

- Create webapp/WEB-INF/web.xml file to be the following :


4. Create ooo-servlet.xml


- Create webapp/WEB-INF/spring-servlet.xml file to be the following :


5. Create a JSP Page

- File > New > JSP file : webapp/WEB-INF/views/welcome.jsp
welcome.jsp file to be the following :


6. Create a Java Class

- File > New > Package > com.yunjee.spring
- File > New > Class > HelloWorldController.java
- HelloWorldController.java file to be the following :


7. Set a Server

- Window > show view > Server
- Create server > Select available project


8. Execute

- Run > Run (Ctrl + F11)
















** Error

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

- Check below Properties if tomcat is set

  • Java Build Path > add Library.. 
  • Targeted Runtimes
  • Project Facets > Runtimes

- Or, add servlet-api in Java Build Path > Libraries


Friday, July 15, 2016

1. Setting Environment

*** 07.15.2016 latest version
*** 08.02.2016 updated
*** based on window 10 64bit


1. Eclipse (eclipse-jee-neon-R-win32-x86_64)

- http://www.eclipse.org/downloads/eclipse-packages/


2. Spring STS 3.8.0

- Install Spring Framework STS 3.8.0
  Help > Install New software > http://springide.org/updatesite  Help > Eclipse Marketplace > search "STS" 

3. Maven

- if you already installed Spring STS 3.8.0, you do not need to install Maven


- https://maven.apache.org/what-is-maven.html
- http://stackoverflow.com/questions/3589562/why-maven-what-are-the-benefits

4. JDK (Java SE Development Kit 8u91)

- http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- After installation, set environment variable

- JAVA_HOME : C:\Program Files\Java\jdk1.8.0_91
- PATH : %JAVA_HOME%\bin
- CLASSPATH : .;%JAVA_HOME%\lib\tools.jar


5. Tomcat (apache-tomcat-9.0.0.M9)

- http://tomcat.apache.org/
- After download Tomcat, unzip in Java folder
- set environment variable

- CATALINA_HOME : C:\Program Files\Java\Tomcat 9.0
- PATH : %CATALINA_HOME%\bin

- exec C:\Program Files\Java\Tomcat 8.5\bin\startup
- check http://localhost:8080/


6. Apache (httpd-2.4.23-win64-VC14)

- https://www.apachelounge.com/download/
- After unzip, relocate C drive : C:\Apache24


7. Connect with tomcat

- http://apache.tt.co.kr/tomcat/tomcat-connectors/jk/binaries/windows/
- download connector using mod_jk

1) Copy mod_jk.so file to C:\Apache24\modules
2) Check server.xml

    <!-- Define an AJP 1.3 Connector on port 8009 -->

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


3) Create workers.properties file at C:\Apache24\conf

    worker.list=worker1
    worker.worker1.type=ajp13
    worker.worker1.host=localhost
    worker.worker1.port=8009

4) Set some parameters to httpd.conf file

    LoadModule jk_module modules/mod_jk.so


    JkWorkersFile conf/workers.properties

    JkLogFile logs/mod_jk.log

    JkLogLevel info



    JkMount /* worker1



* Refer to : http://joont.tistory.com/55

c.f) 
* vcruntime140.dll error
- https://ko.dll-files.com/
- download and copy to C:\Windows\System32

* make annotation (전체 주석)
- C:\Apache24\conf\extra\httpd-vhosts.conf


* 시스템 효용성 및 분산 처리를 위해서 apache 와 tomcat을 연동
  ( WEB Server -> html, WAS Server -> jsp )
* 최신라이브러리 관리와 프로젝트 관리를 위해 Maven 사용