Spring mvc-Environment Setting (reprint practice)

Source: Internet
Author: User
Tags java se

The following content is translated from: https://www.tutorialspoint.com/springmvc/springmvc_environment_setup.htm

Description: The sample is based on spring MVC 4.1.6.

Step 1-Install the Java Development Kit (JDK):

You can download the latest version of the SDK from the Oracle Java site: Java SE Downloads . You will find instructions for installing the JDK in the downloaded file, follow the instructions given to install and configure the settings. Finally, the path and JAVA_HOME environment variables are set to refer to directories containing Java and javac, usually Java_install_dir/bin and Java_install_dir respectively.

If you are running Windows and installing the JDK in C:\jdk1.6.0_15, you must place the following line in the C:\autoexec.bat file.

Set path=c:\jdk1.6.0_15\bin;%path%set java_home=c:\jdk1.6.0_15

or, on Windows NT/2000/XP, you can also right-click My Computer, select Properties, select Advanced, and then select environment variables. Then, you update the path value, and then press the OK button.

On Unix (Solaris,linux, etc.), if the SDK is installed in/usr/local/jdk1.6.0_15, and C shell is used, the following is placed in the. cshrc file.

Set path /usr/local/jdk1.6.0_15/bin:$pathset env java_home/usr/local/jdk1.6.0_15

Or, if you are using an integrated development environment (IDE) such as Borland Jbuilder,eclipse,intellij Idea or Sun one studio, compile and run a simple program to confirm that the IDE knows where to install Java, Otherwise, set it correctly to the IDE for the given document.

Step 2-Install the Apache Common Logging API:

you can get from http://commons.apache.org/logging/ Download the latest version of the Apache Commons Logging API . After downloading the installation, unzip the binary file into a convenient location. For example,/usr/local/commons-logging-1.1.1 on C:\commons-logging-1.1.1 or Linux/unix on Windows. This directory will have the following jar files and other supporting documentation.

Make sure you correctly set the CLASSPATH variable in this directory, or you will face problems when you run the application.

Step 3-Install the Eclipse IDE

all the examples in this tutorial are written using the Eclipse IDE. So I suggest you should install the latest version of Eclipse on your machine.

to install the Eclipse IDE, go from http://www.eclipse.org/downloads/ Download the latest eclipse binaries . After downloading the installation, unzip the binary file into a convenient location. For example, in/usr/local/eclipse on Windows C:\eclipse or Linux/unix, finally set the appropriate path variable.

You can start eclipse by executing the following command on your Windows machine, or you can double-click the Eclipse.exe

C:\eclipse\eclipse.exe

You can start eclipse by executing the following command on a UNIX (solaris,linux, etc.) machine:

/usr/local/eclipse/eclipse

Step 4-Set up the Spring Framework Library

Now if everything is fine, then you can continue to set up your spring framework. Here are the simple steps to download and install the framework on your machine.

    • Make a selection whether you want to install spring on Windows or UNIX, and then continue to the next step to download the. zip file for Windows and.

    • from http://repo.spring.io/release/org/springframework/spring Download the latest version of the Spring framework binary file .

    • at the time of this tutorial writing, I On the Windows machine downloaded the Spring-framework-4.1.6.release-dist.zip , when you unzip the downloaded file, the directory structure within the E:\spring is given as follows.

you will be in the catalog in E:\spring\libs Find all the Spring libraries . Make sure you correctly set the CLASSPATH variable in this directory, or you will face problems when you run the application. If you use Eclipse, you do not need to set classpath because all settings will be completed through eclipse.

After the final step, you can continue with the first spring example, as you'll see in the next chapter.

Step 5-Use MAVEN quick integration

The tutorial above is already very old, but it is really the quickest, you can not learn maven. MAVEN can be integrated quickly on the dependencies of the package, configured as follows:

POM:

<Projectxmlns= "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/maven-v4_0_0.xsd">    <modelversion>4.0.0</modelversion>    <groupId>Com.jsoft.testspring</groupId>    <Artifactid>Testmvchelloworld</Artifactid>    <Packaging>War</Packaging>    <version>0.0.1-snapshot</version>    <name>Testmvchelloworld Maven Webapp</name>    <URL>http://maven.apache.org</URL>    <Dependencies>        <Dependency>            <groupId>Junit</groupId>            <Artifactid>Junit</Artifactid>            <version>3.8.1</version>            <Scope>Test</Scope>        </Dependency>        <!--Servlet Library--<!--HTTP://MVNREPOSITORY.COM/ARTIFACT/JAVAX.SERVLET/JAVAX.SERVLET-API-- <dependency> <groupId>javax.servlet</groupId> <artifactid>javax.servlet        -api</artifactid> <version>3.1.0</version> <scope>provided</scope> </dependency> <!--Spring Core--<!--Http://mvnrepository.com/artifact/org.springframe            Work/spring-core-<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.1.6.RELEASE</version> </depe ndency> <!--Spring Web--<!--Http://mvnrepository.com/artifact/org.springframework/spring-we B--<dependency> <groupId>org.springframework</groupId> <artifactid >spring-web</artifActid> <version>4.1.6.RELEASE</version> </dependency> <!--Spring Web MVC -<!--HTTP://MVNREPOSITORY.COM/ARTIFACT/ORG.SPRINGFRAMEWORK/SPRING-WEBMVC--<dependency&gt            ;            <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.6.RELEASE</version> </dependency>    </Dependencies>    <Build>        <Finalname>Testmvchelloworld</Finalname>        <Plugins>            <!--Config:maven Tomcat Plugin -            <!--Http://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat7-maven-plugin -            <!--http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html -            <plugin>                <groupId>Org.apache.tomcat.maven</groupId>                <Artifactid>Tomcat7-maven-plugin</Artifactid>                <version>2.2</version>                <!--Config:contextpath and Port (default:8080) -                <!--<configuration> <path>/</path> <port> 8899</port> </configuration> -            </plugin>            <!--Config:maven Jetty Plugin -            <!--Http://mvnrepository.com/artifact/org.mortbay.jetty/jetty-maven-plugin -            <!--http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html -            <plugin>                <groupId>Org.eclipse.jetty</groupId>                <Artifactid>Jetty-maven-plugin</Artifactid>                <version>9.4.3.v20170317</version>                <!--Config:contextpath and Port (default:8080) -                <!--<configuration>  -            </plugin>        </Plugins>    </Build></Project>

Spring mvc-Environment Setting (reprint practice)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.