Advanced Java Development class notes (c)

Web services to build

Once you know how to use the IDEA Git, we are ready to start making preparation before development projects.
It requires Java Servlet api and Jetty maven plugins, which can be in two links: https://mvnrepository.com/ download.
Jetty maven plugins to use it as a plug-in:
Here Insert Picture Description
the Java Servlet API Link Maven copy paste the link to the project pom.xml file:
Here Insert Picture Description

Increase the allocation information

Here Insert Picture Description
Click here to add configuration information.
Here Insert Picture Description
Click +to select Maven, enter a project name, Command lineenter the jetty:runclick ok to.
Here Insert Picture Description
Run the program, when the display [INFO] Started Jetty Serversays that the program can be up and running, and this time the port number is 8080, the current path is the path http: // localhost: 8080 /.

Connector Configuration

When our port 8080 is occupied, we can configure the connector to change the port number:

           <connectors>
              <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>8081</port>
                <maxIdleTime>6000</maxIdleTime>
              </connector>
            </connectors>

Here Insert Picture Description
Also in connectorswhich we can modify maxIdleTimeto modify the idle time.

Configuration path

      <webApp>
              <contextPath>/test</contextPath>
            </webApp>

Here Insert Picture Description
After configuring these parameters, re-run the program, you can see at this time of the port number is 8081, and the path is http: // localhost: 8081 / test /.
Here Insert Picture Description
Similarly, copy the Java Servlet api code into the Maven pom.xml file:
Here Insert Picture Description
Finally, the above code, committhe local repository pushto the Gitee can (recommended).
Here Insert Picture Description

Released seven original articles · won praise 0 · Views 198

Guess you like

Origin blog.csdn.net/Vinseny/article/details/105207406