SpringBoot Web development project in IDEA packaged in two ways (jar package)

I believe when bloggers to open web project, will encounter a variety of pit configuration environment, dependent on third-party packages, packing line, and so on, then obviously well run locally, but for a place to run again is blood red, sometimes have the urge to want to hit the computer (calm, the computer is your life children, there is also a lot of gestures have not learned ~~~~ to the teacher), give us today to share my learning these pits when stepped on, She spoke two lines of brine on the trip down! ! ! ! !

 

How to package into a jar of the project will be in two ways IDEA SpringBoot

 

A: function using IDEA comes

Before packing your project to ensure normal operation locally, as shown below

 

 When you see the console output following fields, indicate your development environment and its dependencies were normal, the horse can start packing up! ! !

Before we look at several important packages depend on the pom.xml:

 

 

 

 1. First, select a project name, and then click Projiect Structure upper right corner point, or use the keyboard shortcut Ctrl + Alt + Shift + S

 

 2. Select the Artifacts, then click the + button at the top right, select the second drop-down menu bar JAR point

 

 3, in the pop-up window, fill in your project, the project started classes, replication-dependent packages, etc.

 

 Then all the way click ok, the return code editing, project directory will appear on the left named: META-INF folder inside the file, that your project depends on the path of third-party packages

5. Select the item, click on the Build menu bar, select Build Artficts in the drop-down menu, and then select the Build ... tool in the open field, the compiler will automatically open the pack

 

 

 

 6, after compilation is complete, you can then see the project directory classes -> artifaces next XXX_jar have a name to your project begins, there will be a lot of .jar file opens, there is a jar of your project name indicating that packaging has been completed, to take over is to start it.

 

 7. We open the file manager of the computer, find your letter and path where the project, as

 

 8. Open a cmd window, change the path to your project file Road King, I was in D: \ Java \ intelworkspace \ Photographys \ classes \ artifacts \ photographys_jar

 

 9. After a successful switchover path using your project name java -jar .jar, to run, when the output of the following characters appear, congratulations on your way to start the project by jar success! ! ! ! ! ! !

 

 10. Then to your browser and enter localhost: 9080 / ***** can access the page, such as a 404 error page report, see the article at the beginning of an important dependencies in the pom.xml up, repackaged to

 

 Haha successful, there should be applause here! ! ! ! ! ! ! ! ! ! !

These are the first way, there blog friends would certainly say so much trouble ah, but after the package folder, there are many jar package, in case the project can not delete a package not started, I do not read, Ai Aiai, Sao years do not go, there is a simple method below!

 

Second, the use maven package

1. Select the project name, click on the right-hand column of Maven Projects, open Lifecycle, double-click clean, clear target cache

 

 2, then the first step by double-clicking package, IDEA will automatically start the project all the necessary files and dependencies to be packaged into a jar inside, two magic file directory will appear at the left column of the target file after completion

 

 Yes, the name of the file to your project started, is the final jar package, find it run with java -jar XXXX.jar, so ok

 

Note: If the steps above packed not run, may be substituted into the jar file is not part of the package, the first double-click the top in clean, clear cache after target, re-run the project, and then directly to packaging.

 

Here I recommend use the second approach, easy to deploy to run on a remote server, thank you support, if any shortcomings, welcome to point out!

 

 

 

Guess you like

Origin www.cnblogs.com/sanjay/p/11828081.html