Idea/eclipse MAVEN Engineering integrated Web service (tomcat, jetty)

Source: Internet
Author: User

Idea/eclipse MAVEN Engineering integrated Web service

Reprint Please specify source :http://www.cnblogs.com/funnyzpc/p/8093554.html

  Application server most commonly used by the three:Tomcat, jetty, WebLogic , the former two open source is a lightweight application server, suitable for the general project development environment and production environment, the latter is charged, enterprise-class, large application server; All three have been used by individuals, Generally do small and medium-sized projects when IDE integration jetty to debug and development, Tomcat to do production environment services, as for WebLogic I only used in some of the bank's projects, generally deployed on the Linux server, you need to use the command to start the service, Fortunately, the component configuration is configured in the WebLogic Web service (which includes data sources, logs, external dependencies, clustering, distributed ...). , so it's inconvenient to use WebLogic for local development, well, this chapter I'll talk about how local development integrates jetty or tomcat services.

Whether it's idea or eclipse, there are roughly two ways to configure a project to run ≡(▔﹏▔)≡:

   A> One is IDE integrated Web service

B> One is a project integration Web service

C> start the project through the Main method (not spoken here)

The benefit of IDE's integrated Web services is that I can run on a local Web server regardless of any project, but there may be a problem: If you run multiple projects in the IDE (there are new projects in the old project) will cause the service to fail, this problem I have encountered, but in most cases is not a problem ~ , now that you've talked to IDE integrated Tomcat, let's talk about how to configure it so that ' s go=>

The first thing you need to do is download the Web services software from the official website (for Tomcat, for example,jetty with Tomcat):

You can see several items in the core, the first zip and tar package versions are available for Windows or Linux versions, need to be decompressed, and fourth fifth is the version of Windows system dedicated to 32-bit systems (to be decompressed), 64-bit version of Windows system ( Requires decompression), 32/64-bit installation (no decompression required, the Tomcat service is added automatically after installation, and is used for production environments under Windows systems).

Next eclipse configures Tomcat:

The above configuration requires a version of Tomcat that corresponds to the download, followed by the configuration service name, the Tomcat directory location,and the JRE:

After finishing, select "Run Configurations..." under run. Options:

Well, the project is running. \ (0^◇^0)/, well, here's a question, if it's multiple projects, the port will definitely conflict, if it runs at the same time, it will fail, For the port configuration needs to be configured in Tomcat's server.xml, the modification is very troublesome, as to run at the same time, the individual also found a lot of methods, but all failed, in fact, this problem is not no solution, the next look at how to integrate Tomcat plug-ins in the project, you can configure any port, service will not error!

There are many benefits of engineering integrated Tomcat: The version can be changed at any time, the port can be configured arbitrarily and the project copy to another user's IDE under the direct configuration running can run up, is not very easy,just do it ==>

First, you need to add a plugin (in plugins) to the MAVEN configuration file Pom.xml:

1             <!--maven integrated Tomcat run -2             3             <plugin>4                 <groupId>Org.codehaus.mojo</groupId>5                 <Artifactid>Tomcat6-maven-plugin</Artifactid>6                 <version>1.1</version>7                 <Configuration>8                     <Path>/thirddemo</Path>9                     <Port>8089</Port>Ten                     <uriencoding>UTF-8</uriencoding> One                     <URL>Http://localhost:8089/thirdDemo/student/listStudent</URL> A                     <Server>Tomcat6</Server> -                 </Configuration> -             </plugin>

If you are configuring jetty, add this paragraph:

1 <plugin>2         <groupId>Org.eclipse.jetty</groupId>3         <Artifactid>Jetty-maven-plugin</Artifactid>4         <version>9.4.8.v20171121</version>5         <Configuration>6           <HttpConnector>7             <Port>9092</Port>8           </HttpConnector>9           <Stopkey>Shutdown</Stopkey>Ten           <Stopport>9099</Stopport> One           <Webappconfig> A             <ContextPath>/</ContextPath> -             <!--<contextPath>/${project.artifactId}</contextPath> - -           </Webappconfig> the         </Configuration> -       </plugin>

Should be configured for the above two services I am in two different projects, so you need to consider their own projects to configure the URL and path parameters, otherwise the project can not run is not good.

After configuring the plug-in, the next step is to use MAVEN to configure the command to run without pain ~ ('? ') ?? :

Whether the project is running or not, use the "jetty:run" command if the jetty is configured.

If you are using idea, you need this configuration to run:

If you are an engineering integrated Web service, refer to this configuration:

If the IDE integrates Web services, please refer to the following configuration, click the Run button to run the project after the configuration is complete:

is not huge simple, there is wood ~??

The comfort of the matter is finished, it is time to tell about the pit I have filled ~ ⊙﹏⊙ =

A> mentioned above, if you are not able to use IDE-integrated Web services under the same IDE to run >1 projects at the same time

B> if the port of the Web service is configured under an Apple Mac computer, the port cannot be a four-digit port, or it will not run.

C> Be sure to choose the right version of the Web service depending on the new and old extent of the project and the JDK version you are using, generally, the general rule is to run a lower version of the project with a later version of the Web service, or there will be a strange run error

D> if it is an engineering integrated Web service, using Tomcat, then only the TOMCAT7 version of Tomcat is available (this is the highest plug-in version), if JDK8 and above engineering please bypass the use of jetty, remember!

Finally, give a log that runs successfully:

[WARNING]! Requestlog

[INFO] Started [Email protected]:8088

[INFO] Started Jetty Server

Now is: 2017-12-23-16:46:20

Good evening, everyone-|-_-|-.

Idea/eclipse MAVEN Engineering integrated Web service (tomcat, jetty)

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.