java - tomcat如何启动指定的maven项目?
PHP中文网
PHP中文网 2017-04-18 10:44:06
0
4
573
PHP中文网
PHP中文网

认证0级讲师

reply all(4)
小葫芦

If you are working on the front-end, you should not change the back-end service code easily. Based on this premise, let’s discuss.

  1. Since it is a maven web project, you can use the maven pacakge command to package
    (you can consult if there is anything that needs special attention when packaging back-end children's shoes)

  2. Copy target/project.war to tomcat’s webapps

  3. Start up tomcat
    If there are changes to the backend code, you need to start it all over again


Another way is to add the tomcat plug-in in the pom.xml of the maven project

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <port>8080</port>
        <path>/</path>
        <uriEncoding>UTF-8</uriEncoding>
        <finalName>${project.artifactId}</finalName>
        <server>tomcat</server>
        <systemProperties>
            <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
            <!--
                 <JAVA_OPTS>
                     -server -Xms1024m -Xmx4096m -XX:PermSize=128M -XX:MaxPermSize=2048 -Dfile.encoding=UTF-8
                 </JAVA_OPTS>
             -->
        </systemProperties>
    </configuration>
</plugin>

Run mvn tomcat7:run so you can access the backend service


Consider another situation:

If the backend is the spring-boot project, then you don’t need to do anything, just execute it directly in the project directory mvn spring-boot:run That’s it

伊谢尔伦

Just make it into a war package and throw it into the tomcatwebAPP directory

伊谢尔伦

There is a bin directory under tomcat, and there is a start or something in it. Copy the project into the webapps folder

黄舟

First of all, if your project does not use an IDE, you need to compile it manually. It is very troublesome to compile the project without an IDE. Tomcat needs to run compiled class files, so you cannot specify an uncompiled project when using tomcat directly. of.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template