maven tomcat插件上传项目到tomcat服务器报错SEVERE: One or more listeners failed to start.

以前觉了maven依赖设置很简单,就是将手动导入jar包转化为自动下载导入

但发现的一个问题,

在使用maven插件tomcat打包上传工具时

tomcat-maven-plugin
<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <compilerArgument>-parameters</compilerArgument>
                    </configuration>
                </plugin>

                <!-- tomcat远程部署 -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat-maven-plugin</artifactId>
                    <version>1.1</version>
                    <configuration>
                        <url>http://ip:端口/manager/text</url>
                        <path>/项目名</path>
                        <username>xxxx</username>
                        <password>xxx</password>
                        <server>tomcat</server>
                        <update>true</update>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>

老是出现可以上传war包到服务器,但就是启动不了

就一步步排查问题,找了一大堆,最后我是靠注释掉所有启动时的配置代码,尝试着终于找到问题

问题代码AppConfig.java

        //添加全局的小程序配置
        WxaConfig wc = new WxaConfig();
        wc.setAppId(PropKit.get("wxaappId"));
        wc.setAppSecret(PropKit.get("wxaappSecret"));
        WxaConfigKit.setWxaConfig(wc);

在pom.xml中我的错误依赖代码

        <dependency>
            <groupId>com.jfinal</groupId>
            <artifactId>jfinal-weixin</artifactId>
            <version>1.9</version>
            <scope>provided</scope> 
        </dependency>

我使用的是较新版本的jfinal-weixin-1.9.jar包

而服务器上/usr/local/tomcat/lib目录下的是jfinal-weixin-1.8.jar的jar包

旧版本没有该对应代码,所以就启动不成功了,但奇怪的是我查看tomcat的日志文件却没有明显错误提示,只是说

SEVERE: One or more listeners failed to start.

这个查看详细日志在哪看,这个都不知道,百度也找不到,烦躁

搜索的下,这个

<scope>provided</scope> <!-- compile:开发环境, provided:部署环境 -->

如果是provided时,这个jar包是不会被编译到war包的WEB-INF/lib目录下,项目就会用tomcat/lib目录下的jar包,

      compile,缺省值,适用于所有阶段,会随着项目一起发布。 
    * provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。 
    * runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。 
    * test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。 
    * system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。

 

将该依赖改为下面的,重新编译上传。终于搞定了,为自己的无知又添加了一笔

        <dependency>
            <groupId>com.jfinal</groupId>
            <artifactId>jfinal-weixin</artifactId>
            <version>1.9</version>
            <scope>compile</scope> 
        </dependency>

给一个图吧

 

posted @ 2018-11-01 19:41  海绵般汲取  阅读(306)  评论(0编辑  收藏  举报