老师你好,同一份代码在Ubuntu18会出错,但在Mac和Win系统本地打包一切正常。
来源:14-4 Jenkins任务执行和工作目录简介

慕田峪8226962
2020-03-05
最后更新
花了点时间去验证了一下Win7和Mac14系统都是没问题的但是在Ubuntu18的系统就打包不了老说mapper/SQLMapper.xml有错误。。。大家都是Java1.8MVN都是3.6.x并且一样的代码就Ubuntu会老报错。。。无语~
我将代码在本地可以打包一切正常但是丢上去Linux服务器的Jenkins之后一点构建就会失败我也用命令行直接进去文件夹试过都不行。
看log好像说是SqlSession sqlSession = DatabaseUtil.getSqlSession(); 这句代码有问题我本地没问题但到了别的系统就不行了。。。可以帮忙看看是什么问题么谢谢。
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 1.192 s <<< FAILURE! - in TestSuite
[ERROR] test02(com.api.cases.News) Time elapsed: 0.169 s <<< FAILURE!
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mapper/SQLMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Started by an SCM change
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/JTK
using credential 92f6544d-d436-4f3f-8bbf-d20663e8938f
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/TY-WU/JTK-API.git # timeout=10
Fetching upstream changes from https://github.com/TY-WU/JTK-API.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress -- https://github.com/TY-WU/JTK-API.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision e149bb19fcb07fdaccc388a98f017b1691e37b37 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f e149bb19fcb07fdaccc388a98f017b1691e37b37 # timeout=10
Commit message: "mm"
> git rev-list --no-walk 2ca7148e39273b65a4fa8c976d4bdff9ff5969bb # timeout=10
Parsing POMs
Established TCP socket on 38637
[JTK] $ /usr/java/jdk1.8.0_231/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar:/usr/share/maven/conf/logging jenkins.maven3.agent.Maven35Main /usr/share/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-3.36.1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 38637
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /var/lib/jenkins/workspace/JTK/pom.xml install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.springframework.boot:JTK-API >------------------
[INFO] Building JTK-API 2.2.4.RELEASE
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ JTK-API ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ JTK-API ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to /var/lib/jenkins/workspace/JTK/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ JTK-API ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/JTK/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ JTK-API ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ JTK-API ---
[INFO] No tests to run.
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Test done...
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 1.192 s <<< FAILURE! - in TestSuite
[ERROR] test02(com.api.cases.News) Time elapsed: 0.169 s <<< FAILURE!
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mapper/SQLMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
[ERROR] test01(com.api.cases.Login) Time elapsed: 0.031 s <<< FAILURE!
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mapper/SQLMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
Caused by: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] Login.test01:42 » Persistence
### Error building SqlSession.
### The error ma...
[ERROR] News.test02:66 » Persistence
### Error building SqlSession.
### The error may...
[INFO]
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[ERROR] There are test failures.
Please refer to /var/lib/jenkins/workspace/JTK/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ JTK-API ---
[INFO] Building jar: /var/lib/jenkins/workspace/JTK/target/JTK-API-2.2.4.RELEASE.jar
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ JTK-API ---
[INFO] Installing /var/lib/jenkins/workspace/JTK/target/JTK-API-2.2.4.RELEASE.jar to /var/lib/jenkins/.m2/repository/org/springframework/boot/JTK-API/2.2.4.RELEASE/JTK-API-2.2.4.RELEASE.jar
[INFO] Installing /var/lib/jenkins/workspace/JTK/pom.xml to /var/lib/jenkins/.m2/repository/org/springframework/boot/JTK-API/2.2.4.RELEASE/JTK-API-2.2.4.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.002 s
[INFO] Finished at: 2020-03-05T02:43:26+08:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/JTK/pom.xml to org.springframework.boot/JTK-API/2.2.4.RELEASE/JTK-API-2.2.4.RELEASE.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/JTK/target/JTK-API-2.2.4.RELEASE.jar to org.springframework.boot/JTK-API/2.2.4.RELEASE/JTK-API-2.2.4.RELEASE.jar
channel stopped
Script returned:
[JTK] $ /bin/sh -xe /tmp/jenkins5651840177108291404.sh
+ pwd
/var/lib/jenkins/workspace/JTK
+ whoami
jenkins
+ mvn test
[[1;34mINFO[m] Scanning for projects...
[[1;34mINFO[m]
[[1;34mINFO[m] [1m------------------< [0;36morg.springframework.boot:JTK-API[0;1m >------------------[m
[[1;34mINFO[m] [1mBuilding JTK-API 2.2.4.RELEASE[m
[[1;34mINFO[m] [1m--------------------------------[ jar ]---------------------------------[m
[[1;34mINFO[m]
[[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:3.1.0:resources[m [1m(default-resources)[m @ [36mJTK-API[0;1m ---[m
[[1;34mINFO[m] Using 'UTF-8' encoding to copy filtered resources.
[[1;34mINFO[m] Copying 0 resource
[[1;34mINFO[m] Copying 5 resources
[[1;34mINFO[m]
[[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.8.1:compile[m [1m(default-compile)[m @ [36mJTK-API[0;1m ---[m
[[1;34mINFO[m] Nothing to compile - all classes are up to date
[[1;34mINFO[m]
[[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:3.1.0:testResources[m [1m(default-testResources)[m @ [36mJTK-API[0;1m ---[m
[[1;34mINFO[m] Using 'UTF-8' encoding to copy filtered resources.
[[1;34mINFO[m] skip non existing resourceDirectory /var/lib/jenkins/workspace/JTK/src/test/resources
[[1;34mINFO[m]
[[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.8.1:testCompile[m [1m(default-testCompile)[m @ [36mJTK-API[0;1m ---[m
[[1;34mINFO[m] No sources to compile
[[1;34mINFO[m]
[[1;34mINFO[m] [1m--- [0;32mmaven-surefire-plugin:2.22.2:test[m [1m(default-test)[m @ [36mJTK-API[0;1m ---[m
[[1;34mINFO[m] No tests to run.
[[1;34mINFO[m]
[[1;34mINFO[m] -------------------------------------------------------
[[1;34mINFO[m] T E S T S
[[1;34mINFO[m] -------------------------------------------------------
[[1;34mINFO[m] Running [1mTestSuite[m
Test done...
[[1;31mERROR[m] [1;31mTests [0;1mrun: [0;1m2[m, [1;31mFailures: [0;1;31m2[m, Errors: 0, Skipped: 0, Time elapsed: 1.17 s[1;31m <<< FAILURE![m - in [1mTestSuite[m
[[1;31mERROR[m] test02(com.api.cases.News) Time elapsed: 0.185 s <<< FAILURE!
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mapper/SQLMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
Caused by: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.News.test02(News.java:66)
[[1;31mERROR[m] test01(com.api.cases.Login) Time elapsed: 0.022 s <<< FAILURE!
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in mapper/SQLMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
Caused by: java.io.IOException: Could not find resource mapper/SQLMapper.xml
at com.api.cases.Login.test01(Login.java:42)
[[1;34mINFO[m]
[[1;34mINFO[m] Results:
[[1;34mINFO[m]
[[1;31mERROR[m] [1;31mFailures: [m
[[1;31mERROR[m] [1;31m Login.test01:42 » Persistence
### Error building SqlSession.
### The error ma...[m
[[1;31mERROR[m] [1;31m News.test02:66 » Persistence
### Error building SqlSession.
### The error may...[m
[[1;34mINFO[m]
[[1;31mERROR[m] [1;31mTests run: 2, Failures: 2, Errors: 0, Skipped: 0[m
[[1;34mINFO[m]
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 4.278 s
[[1;34mINFO[m] Finished at: 2020-03-05T02:43:32+08:00
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-surefire-plugin:2.22.2:test[m [1m(default-test)[m on project [36mJTK-API[m: [1;31mThere are test failures.[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] [1;31mPlease refer to /var/lib/jenkins/workspace/JTK/target/surefire-reports for the individual test results.[m
[[1;31mERROR[m] [1;31mPlease refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.[m
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m]
[[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
[[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Execute shell' marked build as failure
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /var/lib/jenkins/workspace/JTK/test-output to /var/lib/jenkins/jobs/JTK/builds/4/htmlreports/Test_20Report
Finished: FAILURE
写回答
1回答
-
大周
2020-03-07
应该是路径有问题 Could not find resource mapper/SQLMapper.xml 这句话比较关键。
012020-03-07
相似问题