NutzCN Logo
问答 程序在eclipse中运行结果与maven打包运行结果不一致的问题
发布于 44天前 作者 Leewell1989 136 次浏览 复制 上一个帖子 下一个帖子
标签: maven

直接上日志吧,不清楚的再补:

这是eclipse中的运行日志:

19:50:56.081 [main] DEBUG org.nutz.resource.Scans - Found 28 resource by src( config/ ) , regex( ^.+[.]js$ )
19:50:56.081 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/monitor.js
19:50:56.081 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/storage-cas.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/indexds.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/monitor.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/handler.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/util.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/loader.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/util.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/launch.js
19:50:56.082 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/datasource.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/storage.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/storage-config.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/runner.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/indexds.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/data.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/job.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/taskflow.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/index.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/index.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/task.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/launch.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/datasource.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/comm.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/service.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/server/comm.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/service.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/afp/data.js
19:50:56.083 [main] DEBUG org.nutz.ioc.ObjectFactory - 获取配置文件:config/aff/util.js

这是打包出来运行的日志:

2017-01-06 20:06:23,052 DEBUG [main] o.n.r.Scans#log [84] Locations for Scans:
[JarResourceLocation [jarPath=lib\seas-timer-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\afp-service-3.3.0.jar], JarResourceLocation [jarPath=lib\aff-store-config-3.3.0.jar], JarResourceLocation [jarPath=lib\slf4j-api-1.6.2.jar], JarResourceLocation [jarPath=lib\gtp-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\nutz-core-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\sigar-1.6.4.jar], JarResourceLocation [jarPath=lib\ucs-adapter-1.1.0.jar], JarResourceLocation [jarPath=lib\afp-api-model-3.3.0.jar], JarResourceLocation [jarPath=lib\aff-client-3.3.0.jar], JarResourceLocation [jarPath=lib\common-util-1.1.0-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\aff-plugin-base-3.3.0.jar], FileSystemResourceLocation [root=D:\aff-server-3.3.0\config], JarResourceLocation [jarPath=lib\aff-afpproxy-3.3.0.jar], JarResourceLocation [jarPath=lib\log4j-1.2.15.jar], JarResourceLocation [jarPath=lib\jdbc-driver-14.jar], JarResourceLocation [jarPath=lib\monitor-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\aff-server-3.3.0.jar], JarResourceLocation [jarPath=lib\afp-data-3.3.0.jar], JarResourceLocation [jarPath=lib\druid-0.2.19.jar], JarResourceLocation [jarPath=lib\aff-plugin-3.3.0.jar], JarResourceLocation [jarPath=lib\afp-model-3.3.0.jar], JarResourceLocation [jarPath=lib\afp-api-3.3.0.jar], JarResourceLocation [jarPath=lib\logback-classic-0.9.30.jar], JarResourceLocation [jarPath=lib\aff-store-cas-1.2.0-SNAPSHOT.jar], JarResourceLocation [jarPath=file:/D:/aff-server-3.3.0/lib/nutz-core-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\junit-4.8.1.jar], JarResourceLocation [jarPath=lib\common-pa-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\lucene-core-3.5.0.jar], JarResourceLocation [jarPath=lib\aff-store-3.3.0.jar], JarResourceLocation [jarPath=lib\sdts-client-2831.jar], JarResourceLocation [jarPath=lib\logback-core-0.9.30.jar], FileSystemResourceLocation [root=D:\aff-server-3.3.0], JarResourceLocation [jarPath=lib\p2000-api-1.1.0.jar], JarResourceLocation [jarPath=lib\afp-server-3.3.0.jar], JarResourceLocation [jarPath=lib\jdom-1.1.jar], JarResourceLocation [jarPath=lib\xstream-1.4.3.jar], JarResourceLocation [jarPath=lib\xpp3_min-1.1.4c.jar], JarResourceLocation [jarPath=lib\nutz-dao-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=lib\xmlpull-1.1.3.1.jar], JarResourceLocation [jarPath=lib\afp-index-3.3.0.jar], JarResourceLocation [jarPath=lib\gcf-1.3.0-SNAPSHOT.jar]]
2017-01-06 20:06:23,090 DEBUG [main] o.n.r.Scans#log [84] Found 47 resource by src( config/ ) , regex( ^.+[.]js$ )
2017-01-06 20:06:23,092 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/task.js
2017-01-06 20:06:23,095 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage-cas.js
2017-01-06 20:06:23,097 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/handler.js
2017-01-06 20:06:23,100 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/task.js
2017-01-06 20:06:23,103 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/indexds.js
2017-01-06 20:06:23,106 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/index.js
2017-01-06 20:06:23,109 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/service.js
2017-01-06 20:06:23,111 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/taskflow.js
2017-01-06 20:06:23,114 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/taskflow.js
2017-01-06 20:06:23,117 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/service.js
2017-01-06 20:06:23,120 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/datasource.js
2017-01-06 20:06:23,123 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage-cas.js
2017-01-06 20:06:23,126 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage-config.js
2017-01-06 20:06:23,129 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/comm.js
2017-01-06 20:06:23,132 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/loader.js
2017-01-06 20:06:23,135 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/job.js
2017-01-06 20:06:23,138 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/data.js
2017-01-06 20:06:23,140 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/monitor.js
2017-01-06 20:06:23,143 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage.js
2017-01-06 20:06:23,146 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/util.js
2017-01-06 20:06:23,149 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/util.js
2017-01-06 20:06:23,152 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/launch.js
2017-01-06 20:06:23,155 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage.js
2017-01-06 20:06:23,157 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/index.js
2017-01-06 20:06:23,160 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/service.js
2017-01-06 20:06:23,163 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/loader.js
2017-01-06 20:06:23,166 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/indexds.js
2017-01-06 20:06:23,169 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/data.js
2017-01-06 20:06:23,172 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/datasource.js
2017-01-06 20:06:23,175 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/monitor.js
2017-01-06 20:06:23,177 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/indexds.js
2017-01-06 20:06:23,180 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/launch.js
2017-01-06 20:06:23,183 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/job.js
2017-01-06 20:06:23,186 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/index.js
2017-01-06 20:06:23,188 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/comm.js
2017-01-06 20:06:23,191 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/server/launch.js
2017-01-06 20:06:23,194 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/data.js
2017-01-06 20:06:23,197 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/handler.js
2017-01-06 20:06:23,199 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/runner.js
2017-01-06 20:06:23,202 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/monitor.js
2017-01-06 20:06:23,205 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/runner.js
2017-01-06 20:06:23,208 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/storage-config.js
2017-01-06 20:06:23,210 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/datasource.js
2017-01-06 20:06:23,213 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/util.js
2017-01-06 20:06:23,216 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/util.js
2017-01-06 20:06:23,219 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/comm.js
2017-01-06 20:06:23,222 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/afp/util.js

----------------------------------------------------
扫描的配置文件个数都不一样...eclipse里边是正确的,程序能正常运行

26 回复

有重复的

2017-01-06 20:06:23,213 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/util.js
2017-01-06 20:06:23,216 DEBUG [main] o.n.i.ObjectFactory#log [84] 获取配置文件:config/aff/util.js

是的,有的是重复的,有的是实际打包出来的目录下边压根没有的...

哪一个是没有的?

config/server 下边的都是没有的,因为这个目录是不存在的

FileSystemResourceLocation [root=D:\aff-server-3.3.0]

是不是这个目录下面的 D:\aff-server-3.3.0\config

既然没有,那就在D盘全局搜索搜索一下index.js和indexds.js吧

另外,把eclipse环境下的"Locations for Scans"也贴一下,对比一下看看哪个地方不一样

不对呢, 在eclipse运行的结果里面, 一样有config/server/indexds.js

我的eclipse在D盘,搜到的都是workspace下边的
eclipse环境下的"Locations for Scans"

20:27:55.084 [main] DEBUG org.nutz.resource.Scans - Locations for Scans:
[JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\common-pa\1.0.0-SNAPSHOT\common-pa-1.0.0-SNAPSHOT.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-store\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\com\oracle\driver\jdbc-driver\14\jdbc-driver-14.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-plugin\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\org\seas\seas-timer\1.0.0-SNAPSHOT\seas-timer-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\alibaba\druid\0.2.19\druid-0.2.19.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\ch\qos\logback\logback-core\0.9.30\logback-core-0.9.30.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-client\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\org\slf4j\slf4j-api\1.6.2\slf4j-api-1.6.2.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\sugon\p2000-api\1.1.0\p2000-api-1.1.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\log4j\log4j\1.2.15\log4j-1.2.15.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-model\3.3.0\cmp-model-3.3.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-service\3.3.0\cmp-service-3.3.0.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-server\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-api\3.3.0\cmp-api-3.3.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\org\fusesource\sigar\1.6.4\sigar-1.6.4.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-plugin-base\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\org\apache\lucene\lucene-core\3.5.0\lucene-core-3.5.0.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-cmpproxy\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\org\nutz\nutz-dao\1.48.2-SNAPSHOT\nutz-dao-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-server\3.3.0\cmp-server-3.3.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\gcf\1.3.0-SNAPSHOT\gcf-1.3.0-SNAPSHOT.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\monitor\1.0.0-SNAPSHOT\monitor-1.0.0-SNAPSHOT.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-data\3.3.0\cmp-data-3.3.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\common-util\1.1.0-SNAPSHOT\common-util-1.1.0-SNAPSHOT.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\gtp\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\com\shareit\sdts\sdts-client\2831\sdts-client-2831.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-store-config\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-api-model\3.3.0\cmp-api-model-3.3.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\thoughtworks\xstream\xstream\1.4.3\xstream-1.4.3.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-store-cas\target\classes], JarResourceLocation [jarPath=D:\develop\m2.repository\com\huawei\ucs\ucs-adapter\1.1.0\ucs-adapter-1.1.0.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\ch\qos\logback\logback-classic\0.9.30\logback-classic-0.9.30.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\com\geor\cmp\cmp-index\3.3.0\cmp-index-3.3.0.jar], FileSystemResourceLocation [root=D:\develop\workspace\eclipse\geor\plat\grs-parent\grs-server], JarResourceLocation [jarPath=D:\develop\m2.repository\org\nutz\nutz-core\1.48.2-SNAPSHOT\nutz-core-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=file:/D:/develop/m2.repository/org/nutz/nutz-core/1.48.2-SNAPSHOT/nutz-core-1.48.2-SNAPSHOT.jar], JarResourceLocation [jarPath=D:\develop\m2.repository\org\jdom\jdom\1.1\jdom-1.1.jar]]

数了一下. config/server下有9个文件, eclipse和打包后的数量一样.

// server下的js有9个
47 - 9 = 38
28 -9 = 19
// 38刚好是19*2

然后我写个小程序查重了一下, 非server下的js, 均出现2次.

因为打包后扫描日志中,FileSystemResourceLocation只有2个, 而且是父子文件夹的关系, 所以jar里面有js的可能性最大.

嗯,我把他们插到数据库里边查的,去掉重复数量是一致的。

嗯,看到了,主程序的JAR包把resource下边的两个目录都给打进去了

那么问题来了,怎么样让mvn install的时候不把配置文件放进去

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>2.3</version>
  <configuration>
    <excludes>
      <exclude>**/*.js</exclude>
    </excludes>                    
  </configuration>
</plugin>

用这段搞定了

<resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                <exclude>**/*.*</exclude>
                </excludes>
            </resource>
        </resources>

但是出现了新的问题,也是最开始的问题:我在本机启动程序,连接数据库都正常,部到服务器上连不上数据库:

Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection

在这台服务器上能ping通数据库服务器,telnet数据库服务端口也正常,最开始就是这个问题,我以为是数据库配置没生效,就去找配置的问题,现在配置问题已解决,还是报这个问题。防火墙两台机器都关闭了。

"The Network Adapter could not establish the connection", 重启机器和路由器.

服务器是数据库的还是应用的?

PS: resources配置这个不是个好想法

resources这样配,会让maven认为没有任何资源文件, 所以filtering=true没意义. 要是web项目, 打包成war的时候, 这些资源文件一样会被忽略.

还有就是 mvn test的时候, 一个配置文件都找不到...

好的,用你给的。

服务器重启了,依旧连不上...

重新部署了一边,问题解决了。

贴图片的功能什么时间更新啊..

添加回复
请先登陆
回到顶部