springboot多模块项目打war包

一、父模块配置

1,指定pakaging:pom

2,指定编译的版本:如下图:

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

3,屏蔽内置的tomcat:

  (1)这个内置的tomcat是在spring-boot-starter-web这个start中引入的,所以说:

      1)如果你的项目里面用到了这个starter(如下),就加上下面蓝色框中的代码将内置的tomcat屏蔽掉

      2)如果你的项目里面没用到这个starter,就不会有内置的tomcat,这一条就可以跳过。 

      3)在大多数项目中都是有用到这个starter中的,而且可能很多子模块中也用到了这个starter,所以可以在父模块中添加(子模块中不需要在添加),并屏蔽内置tomcat,如下:   

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!--忽略内嵌tomcat,打包部署到tomcat。注*本地运行的时候要把这一段忽略引入个注释掉,要不然项目启动不了 -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

4, 关于对子模块的依赖:

  (1)没有用到子模块可以不写

  (2)用到哪个配哪个:如下:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-static</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-infrasture</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-user</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-service-autho</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement> 

5,子模块配置:

    <modules>
        <module>micro-service-static</module>
        <module>micro-service-infrasture</module>
        <module>micro-servcice-user</module>
        <module>micro-service-autho</module>
        <module>micro-service-run</module>
    </modules>

6,配置文件配置(该设置可在父模块中统一设置,也可以在子模块中单独设置)

在没有配置的时候报错,找不到transaction.xml。

出错原因:配置文件没有打进war包

需要做如下配置:

        <!-- 解决读不到配置文件的问题,将指定的文件打进war包 -->
        <resources>
            <resource>
                <!-- 要打进war包的文件所在的目录 -->
                <directory>src/main/resorce</directory>
                <includes>
                    <include>**.*</include>
                    <include>**/*.*</include>
                    <include>**/*/*.*</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>

7,父模块完整的xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.18.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.googosoft.microservice</groupId>
    <artifactId>googosoft-micro-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>googosoft-micro-service</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>
    <!--  只配置依赖到的即可 -->
<!--     <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-static</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-infrasture</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-servcice-user</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.googosoft.microservice</groupId>
                <artifactId>micro-service-autho</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement> -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- 在父模块中配置,子模块无需在配置 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!--忽略内嵌tomcat,打包部署到tomcat。注*本地运行的时候要把这一段忽略引入个注释掉,要不然项目启动不了 -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <!--用于编译jsp -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <!-- 子模块配置 -->
    <modules>
        <module>micro-service-static</module>
        <module>micro-service-infrasture</module>
        <module>micro-servcice-user</module>
        <module>micro-service-autho</module>
        <module>micro-service-run</module>
    </modules>
</project>

二、子模块-启动模块配置

1,指定父模块:

    <parent>
        <groupId>com.googosoft.microservice</groupId>
        <artifactId>googosoft-micro-service</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

2,packaging设置:

这里我需要一个war包,所i一指定成war

<packaging>war</packaging>

3,指定依赖的子模块

如果依赖的模块的packaging为war,就必须配置type,classifier,否则会报下错:

正确的配置:

        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-user</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-service-autho</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-infrasture</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>

4,打war包插件设置

        <plugins>
            <!-- war包插件 -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <!-- 把class打包jar作为附件 -->
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>
            <!-- 指定启动入口 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.googosoft.UserBootApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>

5,指定启动入口

            <!-- 指定启动入口 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.googosoft.UserBootApplication</mainClass>
                </configuration>
            </plugin>

除了上面的配置还需要加Initializer继承SpringBootServletInitializer重写SpringApplicationBuilder方法,如下:

package com.googosoft;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(UserBootApplication.class);
    }
}

不重写报错:

重写后:

6,启动模块完整pom.xml

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.googosoft.microservice</groupId>
        <artifactId>googosoft-micro-service</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>com.googosoft.microservice</groupId>
    <artifactId>micro-service-run</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>micro-service-run</name>
    <packaging>war</packaging>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-user</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-service-autho</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-infrasture</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错  -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
    </dependencies>
    <build>
        <!-- 为jar包取名 -->
        <finalName>micro-service-run</finalName>
        <plugins>
            <!-- war包插件 -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <!-- 把class打包jar作为附件 -->
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>
            <!-- 指定启动入口 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.googosoft.UserBootApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

三、子模块-packaging为war的模块设置

1,packaging设置:war

设置为war后必须添加plugin

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <!-- 把class打包jar作为附件 -->
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>

2,模块依赖设置

        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-infrasture</artifactId>
            <type>jar</type>
            <classifier>classes</classifier>
            <version>0.0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

3,packaging为war的子模块的完整的pom.xml

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.googosoft.microservice</groupId>
        <artifactId>googosoft-micro-service</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>micro-servcice-user</artifactId>
    <name>micro-servcice-user</name>
    <url>http://maven.apache.org</url>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.15</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>3.1.0</version>
        </dependency>
        <!-- poi-ooxml XSSF is our port of the Microsoft Excel XML (2007+) file
            format (OOXML) to pure Java -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sf.ezmorph/ezmorph -->
        <dependency>
            <groupId>net.sf.ezmorph</groupId>
            <artifactId>ezmorph</artifactId>
            <version>1.0.6</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.wso2.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.wso2.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.1.wso2v1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/at.bestsolution.efxclipse.eclipse/com.google.gson -->
        <!-- <dependency> -->
        <!-- <groupId>at.bestsolution.efxclipse.eclipse</groupId> -->
        <!-- <artifactId>com.google.gson</artifactId> -->
        <!-- <version>2.2.4</version> -->
        <!-- <scope>system</scope> -->
        <!-- <systemPath>${basedir}/lib/com.google.gson-2.2.4.jar</systemPath> -->
        <!-- </dependency> -->
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/eu.bitwalker/UserAgentUtils -->
        <dependency>
            <groupId>eu.bitwalker</groupId>
            <artifactId>UserAgentUtils</artifactId>
            <version>1.21</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <!-- <version>1.9.4</version> -->
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
        <!-- <dependency> -->
        <!-- <groupId>org.apache.commons</groupId> -->
        <!-- <artifactId>commons-collections4</artifactId> -->
        <!-- <version>4.4</version> -->
        <!-- </dependency> -->
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <!-- <dependency> -->
        <!-- <groupId>org.apache.commons</groupId> -->
        <!-- <artifactId>commons-lang3</artifactId> -->
        <!-- <version>3.9</version> -->
        <!-- </dependency> -->
        <!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib -->
        <!-- <dependency> -->
        <!-- <groupId>net.sf.json-lib</groupId> -->
        <!-- <artifactId>json-lib</artifactId> -->
        <!-- <version>2.2.3</version> -->
        <!-- <scope>system</scope> -->
        <!-- <systemPath>${basedir}/lib/json-lib-2.2.3-jdk13.jar</systemPath> -->
        <!-- </dependency> -->

        <!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-service-static</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!--单测 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--jdbc -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- mysql驱动 -->
        <!-- <dependency> -->
        <!-- <groupId>mysql</groupId> -->
        <!-- <artifactId>mysql-connector-java</artifactId> -->
        <!-- </dependency> -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.3.8.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.jslsolucoes</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>com.googosoft.microservice</groupId>
            <artifactId>micro-servcice-infrasture</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <!-- 该模块的packaging为war,所以下面两项必须设置,否则打包会出出错 -->
            <type>jar</type>
            <classifier>classes</classifier>
        </dependency>
    </dependencies>
    <build>
        <!-- 为jar包取名 -->
        <finalName>micro-servcice-user</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <!-- 把class打包jar作为附件 -->
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>
            <!-- 热布署 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-- <configuration> -->
                <!-- fork : 如果没有该项配置,这个devtools不会起作用,即应用不会restart -->
                <!-- <fork>true</fork> -->
                <!-- <mainClass>com.googosoft.UserBootApplication</mainClass> -->
                <!-- <layout>ZIP</layout> -->
                <!-- </configuration> -->
                <!-- <executions> -->
                <!-- <execution> -->
                <!-- <goals> -->
                <!-- <goal>repackage</goal>可以把依赖的包都打包到生成的Jar包中 -->
                <!-- </goals> -->
                <!-- </execution> -->
                <!-- </executions> -->
            </plugin>
        </plugins>
    </build>
</project>

四、子模块-静态模块配置

1,packaging:设置为jar即可

2,文件打包目录

五、其他设置

(1)依赖中尽量不要引用外部jar包

(我在开始使用的下面的方式,打包)

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.15</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/poi-ooxml-schemas-3.15.jar</systemPath>
        </dependency>

项目运行时报错:classNotFound

将后两行去掉,项目就可以正常运行了,引用外部jar包应该是可以使用的,但是可能需要额外的配置,最好不要使用。

原文地址:https://www.cnblogs.com/excellencesy/p/12037521.html

时间: 2024-11-06 09:28:09

springboot多模块项目打war包的相关文章

如何将一个SpringBoot简便地打成一个war包(亲测有效)

正常情况下SpringBoot项目是以jar包的形式,通过命令行: 来运行的,并且SpringBoot是内嵌Tomcat服务器,所以每次重新启动都是用的新的Tomcat服务器.正因如此,也出现了一个问题: 上传到项目的文件,如果是保存在项目中的,那么重启过后文件就会丢失.比如我们上传了一个头像,重启项目后,这个头像就没了.而如果将文件保存在本地磁盘中的话,html中标签没办法获取.因此,我们才需要将SpringBoot项目打成war包,放到Tomcat中去运行. 在pom.xml文件中添加下面的

关于传统项目打成war包的的分析

技术在不断的革新,以前的项目没有jar管理工具时,都是手动将依赖的jar拷贝到项目之下,然后Build Path,之后Maven出现了,出现了jar包中央仓库,所有的jar包资源集中在这里,免去频繁去网络上查找jar包的麻烦.Maven采用坐标对一个jar进行定位,使每个jar包在中央仓库中有唯一标识.后面出现的Gradle,原理和Maven类似,且有更多的新特性. 说回传统项目,通过Eclipse创建一个动态web项目(Dynamic Web Project),其目录结构如下: │ .clas

将web项目打成war包部署在tomcat步骤

1.将自己的项目打成war包. 2.将打包好的war复制到${tomcat.home}/webapps项目下. 3.在${tomcat.hom}/conf目录下打开server.xml文件,找到Host节点,在Host节点下添加: <Context docBase="D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Products.war" path="/Products" relo

Web项目打成war包部署到tomcat时报MySQL Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)错误解决方案

Web项目使用使用root账号root密码进行部署,通过Eclipse加载到Tomcat服务器可以发布成功,打成war包放到tomcat的webapps目录无法发布成功,报错: jdbc.properties涉及Mysql配置: 错误很明显,与MySQL密码有关,但是两种方式部署项目使用的jdbc.properties配置文件是一样的.所以肯定不是密码不对引起的,只好找度娘,O(∩_∩)O哈哈~. 网上大部分帖通过运行mysql -u root -p命令登录时也会报这个错误,所以,我就尝试这种方

Web项目打成war包部署Tomcat时运行startup.bat直接闪退部署失败解决方案

即上篇通过将web项目打成war包部署到Tomcat服务器,解决mysql问题后,又出现了新问题,真是一波三折,所以将解决过程分享给大家,希望能帮助到小伙伴们~ 将打好的war包拷贝到Tomcat的webapps目录,然后在Tomcat的bin目录找到startup.bat批处理文件,直接双击执行,结果运行几秒后直接闪退,顿时有种不好的预感,在浏览器访问web项目,结果连localhost:8080都无法访问,web项目未发布成功,一脸懵逼~ 没有日志看不到为啥发布不成功额,想了想,可以稍微修改

maven中打包项目为war包的pom.xml配置

maven中打包成war包的pom.xml配置(1)完整配置:这个是使用servlet的完整配置,其他的类似. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven

2017-09-26 发布 SpringBoot多模块项目实践(Multi-Module)

https://segmentfault.com/a/1190000011367492?utm_source=tag-newest 2017-09-26 发布 SpringBoot多模块项目实践(Multi-Module) 原文地址:https://www.cnblogs.com/javajetty/p/9955082.html

SpringBoot项目打war包部署Tomcat教程

一.简介 正常来说SpringBoot项目就直接用jar包来启动,使用它内部的tomcat实现微服务,但有些时候可能有部署到外部tomcat的需求,本教程就讲解一下如何操作 二.修改pom.xml 将要部署的module的pom.xml文件<packaging>节点设置为war <!-- 默认打包方式为jar,如果是用module做父级则需要修改为pom,如果使用外部tomcat可以修改为war, 子级module的打包方式只能是jar或者war --> <packaging

springboot项目打war包pom设置

<build> <finalName>PayManager</finalName><!--打包后的名字PayManager.war--> <plugins> <!-- <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </