First, the goal
In this post. I'm going to show you how to create your first Java EE application using Spring frameworks and Maven build .
Second, information
Maven is a Building tool for a Java project (or self-building tools). It 's very much wanted with Ant or Gradle . Maven can proactively download components that are dependent on your project.
Third, the requirements
1 . Spring Tool Suite (STS) applied to Java EE (Http://spring.io/tools/sts/all ).
Please select the appropriate installation file for your operating system.
I prefer to download a packaged version number that has portability.
2. Network connection
For the first time you create a spring MVC project, you need a computer network, because you need to Download some project templates from spring Repository.
Maven also need to download some Spring the dependency.
So make sure your computer is connected to the Internet. If you are in an environment where the agent is online, please refer to this tutorial.
Iv. Introduction of configuration
1. Open your STS and select new->spring Project.
2. Name your project ( For example:hellospringmvc) and select the Spring MVC project template.
3, STS will download the corresponding template.
4. Name your top-level package (for example:org.munif.app) and click Finish.
5, observe your project structure, your project will produce inexplicable errors. That's right. Since we have not yet used Maven to join Spring 's dependencies.
6. Right click on your Spring MVC project and select Run Sa->maven install. Watch the output console form to see if there is an installation progress. Once the installation is complete, you are ready to proceed to the next steps.
7. Right-click your Spring MVC project. Select Maven--Update Project.
8. Select your project and click OKuntil the update process is complete.
Look, there's no mistake.
9. Execute your project, right click on the project directory and select Run as, run on Server.
10. Select your java EE service "VMware vfabrics TC Server is provided by STS.", assuming you want to use an Apache that is executed independently tomat . Please make the corresponding configuration.
11, complete. Your project should be able to be presented in an Eclipse -embedded web browser.
Five, frequently asked questions
1, problem #1
Build Workspace error ... couldn ' t find build Plan ... ..
Cause: Your Maven dependencies are not downloaded or are not available.
The workaround:
A. Make sure your computer is connected to the Internet.
B. Right-click your Spring MVC Project and choose Run as -- Maven install. Watch the output text form. Look at the installation progress.
Wait until the installation is complete and you are ready to proceed to the next step.
C. Right-click your Spring MVC Project and choose Maven- - Update project.
2, problem #2
You is behind a proxy
Cause: Your network environment is proxy Internet.
How to resolve:
A. Add the proxy configuration to your setting.xml file.
On entering the Preference. Set this file as a Maven settings file . ( Somehow , settings.xml The default is not created. So you need to create this file yourself. )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
< Settings xmlns= " http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi= " http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= " http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> < proxies > < Proxy > < ID >myproxy</ ID > < Active >true</ Active > < Protocol >http</ Protocol > < Host >proxy.somewhere.com</ Host > < Port >8080</ Port > < username >proxyuser</ username > < Password >somepassword</ Password > < nonproxyhosts >*.google.com|ibiblio.org</ nonproxyhosts > </ Proxy > </ proxies > </ Settings > |
B. Right-click your Spring MVC Project and choose Run as -- Maven->maven install. Observe the output console form to ensure that the installation progress is complete.
C. Right-click your Spring MVC Project and choose Maven- - Update project.
3, problem #3
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
Typically, this error occurs in the Jsp file. Please refer to: http://stackoverflow.com/questions/15434817/ Can-not-find-the-tag-library-descriptor-for-http-java-sun-com-jsp-jstl-core.
After. You can update projects with Maven install and Update Project .
4, Problem #4
When you perform a Maven install . Again there will be errors such as the following:
[ERROR] ... very long ERROR ...: invalid LOC header (bad signature).
Cause: This indicates that it is very likely that there are some dependencies of binary file corruption.
How to resolve:
Delete ". M2/repository" and then perform the Maven install again download dependency repository.
5, problem #5
[ERROR] ... very long errors ...: unresolvedaddressexception
Reason:
A, assume that you use the domain name in the settings.xml file agent (such as :p roxy.its.ac.id), it means that your DNS This domain name address cannot be resolved.
B. Suppose you connect directly to the network, but you still use proxy configuration in Settings.xml.
How to resolve:
A, if the first case, in the settings.xml file with the IP address proxy to replace the domain name.
B, assume direct networking. Delete The proxy configuration in the Settings.xml file.
Finally, hopefully this tutorial will help you use the STS to do the Spring MVC Development.
Vi. references
[1] http://www.mkyong.com/web-development/how-to-configure-proxy-settings-in-eclipse/
[2] http://maven.apache.org/settings.html
[3] http://stackoverflow.com/questions/13044628/spring-error-during-build
English Original: http://abdulmuneverlose.wordpress.com/2013/12/19/ first-spring-mvc-project-using-spring-tool-suite-sts-and-maven-build/
The first spring MVC project built with spring Tool Suite (STS) and Maven