반응형

 

 

 

 

 

 

 

We will gonna execute project in Eclipse.

1. new > maven project > maven-archetype-webapp > enter an artifact id > finish

 

2. changing java version in pom.xml

1.7 -> 1.8

 <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

 

 

 

3. add servlet dependency at pom.xml

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    
     <dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.45</version>
	</dependency>

And don't forget to click [ maven > Update Project ] to adapt the settings.

Restart Eclipse.

 

 

 

4. Editing Web.xml

 

Open Navigator

src > main > webapp > WEB-INF > web.xml

 

change from

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
</web-app>

to

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

 

 

 

 

5. Change web module version

 

open navigator

.settings/org.eclipse.wst.common.project.facet.core.xml

 

You can see like this in xml file

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="2.3"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.8"/>
</faceted-project>

 

change version from "2.3" to "3.1"

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="3.1"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.8"/>
</faceted-project>

 

 

 

 

 

 

 

 

 

6. Make src/main/java 

 

src > main > [ make java file ]

And there will be src/main/java

 

and make package which names like 'kr.or.connect.blahblah'

 

 

 

 

So, our Maven Setting is all end

 

 

반응형

+ Recent posts