12 Ekim 2015 Pazartesi

Spring MVC 4 Maven Projesi - 1

spring maven
          Spring MVC 4 Netbeans IDE ile Maven Projesi Oluşturma




Başla

Kullanılan Teknolojiler

  • Netbeans IDE 8.0.2
  • Maven 4.0.0
  • Spring 4.1.6.RELEASE
  • Glashfish 4.1
  • Java EE 7

Netbeans' de Maven alt yapısı hazır olarak gelmektedir.

Adım 1:

Aşağıdaki gibi projeyi oluşturalım.




Adım 2:

Oluşan proje yapısında Project Files altında pom.xml açalım. Spring için gerekli dependency' leri ekleyelim.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>MavenSpring</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>MavenSpring</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- spring-context which provides core functionality -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>4.1.6.RELEASE</version>
  </dependency>
 
  <!-- The spring-aop module provides an AOP Alliance-compliant aspect-oriented 
   programming implementation allowing you to define -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>4.1.6.RELEASE</version>
  </dependency>
 
  <!-- The spring-webmvc module (also known as the Web-Servlet module) contains 
   Spring’s model-view-controller (MVC) and REST Web Services implementation 
   for web applications -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>4.1.6.RELEASE</version>
  </dependency>
 
  <!-- The spring-web module provides basic web-oriented integration features 
   such as multipart file upload functionality and the initialization of the 
   IoC container using Servlet listeners and a web-oriented application context -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>4.1.6.RELEASE</version>
  </dependency>
                
                 <dependency>  
                        <groupId>javax.servlet</groupId>  
                        <artifactId>javax.servlet-api</artifactId>  
                        <version>${javax.servlet.version}</version>  
                        <scope>provided</scope> 
                </dependency> 

                <dependency>  
                        <groupId>jstl</groupId>  
                        <artifactId>jstl</artifactId>  
                        <version>${jstl.version}</version>  
                </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>


Adım 3:

Gerekli kütüphanelerin indirilmesi için projeyi Build edelim.


Spring MVC 4 Annotation Hello World Uygulaması İçin     Buradan    Geçebilirsiniz.

Bitir

Hiç yorum yok:

Yorum Gönder