Programming     Travel Logs     Life Is Good     Surfing Online     About Me
If you can’t code, write books and blogs, record videos and podcasts.
-Naval Ravikant
2018-05-09 21:58:10

Copy this link when reproducing:
http://www.casperlee.com/en/y/blog/82

/Images/20170924/01.jpg

/Images/20170924/02.jpg

/Images/20170924/03.jpg

/Images/20170924/04.jpg

/Images/20170924/05.jpg

/Images/20170924/06.jpg

1. Make sure JDK, Tomcat server, and Eclipse have been installed to the computer and configured properly. Please see http://www.casperlee.com/x/y/blog/78 for detail steps.

2. Run Eclipse.

/Images/20170905/07.jpg

3. Select "File -> New -> Project..." from the menu.

/Images/20170905/08.jpg

4. Select "Maven -> Maven Project" and click "Next >" to continue.

/Images/20170905/09.jpg

5. Click "Next >" to continue.

/Images/20170905/10.jpg

6. Select the maven-archetype-quickstart, and click "Next >" to continue.

/Images/20170905/11.jpg

7. Type in "Group Id", "Artifact Id", and "Package name", click "Finish", a maven project will be created.

/Images/20170905/12.jpg

8. Open "pom.xml", you will find a section named "dependencies". Put the dependencies into this section, for instance:

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>

9. Save the file, a dialog popped up. Eclipse will download the framework for us automatically.

/Images/20170905/13.jpg

10. After the downloading process finished, the jars will be downloaded to the computer.

/Images/20170905/14.jpg

Note: When using these jars, you may encounter the "invalid LOC header" error:

...
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
	at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
	... 33 more
...

This is a problem of corrupted jars. Here is the solution to fix this error:

1. Use 7-Zip (http://www.7-zip.org/) or what ever you like to unzip all of those downloaded jars one by one, and figure out which jars are corrupted.

2. Delete the corrupted jars in the "C:\Users\[UserName]\.m2\repository" directory.

/Images/20170914/101.jpg

3. Right click on the maven project which has been used to download those jars, select "Maven -> Update Project...".

/Images/20170914/102.jpg

4. Tick "Force Update of Snapshots/Releases", click "OK" to download the library again.

5. If it still doesn't work, repeat these steps until a non-corrupted file is downloaded.