日期: 2016-7-17
内容: Tomcat错误
4.0.0
com.spring
Spring_Struts_HibernateWebProject
0.0.1-SNAPSHOT
jar
使用Maven搭建SSH框架
http://maven.apache.org
junit
junit
4.10
test
org.springframework
spring-core
4.1.3.RELEASE
org.springframework
spring-context
4.1.3.RELEASE
org.springframework
spring-webmvc
4.1.3.RELEASE
org.springframework
spring-web
4.1.3.RELEASE
org.springframework
spring-orm
3.2.4.RELEASE
org.springframework
spring-beans
4.1.3.RELEASE
org.springframework
spring-aop
4.1.3.RELEASE
org.hibernate
hibernate-core
4.3.4.Final
mysql
mysql-connector-java
5.1.38
webDemo
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
packages
run
在maven布置的项目中的pom.xml中添加tomcat7-maven-plugin插件并运行clean package的时候发现如下错误:
错误信息:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring_Struts_HibernateWebProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Spring_Struts_HibernateWebProject ---
[INFO] Deleting E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Spring_Struts_HibernateWebProject ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Spring_Struts_HibernateWebProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 11 source files to E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[6,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[7,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[8,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[28,10] 找不到符号
符号: 类 Before
位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[35,10] 找不到符号
符号: 类 After
位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[42,10] 找不到符号
符号: 类 Test
位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[54,10] 找不到符号
符号: 类 Test
位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[73,10] 找不到符号
符号: 类 Test
位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[85,10] 找不到符号
符号: 类 Test
位置: 类 com.test.test.TestSpringCase
[INFO] 9 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.897 s
[INFO] Finished at: 2016-07-17T07:48:32+08:00
[INFO] Final Memory: 15M/141M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure: Compilation failure:
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[6,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[7,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[8,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[28,10] 找不到符号
[ERROR] 符号: 类 Before
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[35,10] 找不到符号
[ERROR] 符号: 类 After
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[42,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[54,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[73,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[85,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
提示我的Junit包不存在,这不是开玩笑嘛?我找了一下在如下目录下有:
有网友这么描述并解决问题的:Installed JREs 使用本机的JDK,这样貌似可以解决部分问题:具体操作如下:
如何查看自己本机的JDK呢?
之后改为自己本机的JDK;
改变之后的错误藐视确实和之前的不太一样了。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring_Struts_HibernateWebProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Spring_Struts_HibernateWebProject ---
[INFO] Deleting E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Spring_Struts_HibernateWebProject ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Spring_Struts_HibernateWebProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 11 source files to E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.096 s
[INFO] Finished at: 2016-07-17T08:18:34+08:00
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
基本错误描述就是说编译的jdk不相符导致的,因此可以,看了一下项目的jdk确实是这样的。我已经我项目的jdk改成了1.8.0_77但是项目的jdk还是
因此在这里必须手动改变一下jdk版本:
改变之后的jre版本如下:
重新运行之后的结果如下:错误信息还是如下:尝试失败,但是又排除了一种可能,还是有进步的,继续探索。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring_Struts_HibernateWebProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Spring_Struts_HibernateWebProject ---
[INFO] Deleting E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Spring_Struts_HibernateWebProject ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Spring_Struts_HibernateWebProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 11 source files to E:\Java Work\Java Source\Spring_Struts_HibernateWebProject\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.024 s
[INFO] Finished at: 2016-07-17T08:29:33+08:00
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
再次尝试解决:“”我也出现了这种情况 改变系统的jdk 而不是jre 或者升级jdk版本我也出现了这种情况 ”这是在CSDN上的其他同仁给出的意见,抱着尝试的心态去试试。但是怎么改变Eclipse中的JDK版本的?
需要解决的问题: 怎么改变或者更新eclipse中的JDK版本?
其实在运行的结果中已经很明确的指定了错误信息了。
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我电脑上的JDK找不到,查看不了源码,因此打算卸载了重新安装JDK和JRE;
重新安装JDK8的安装教程:http://jingyan.baidu.com/article/ab69b270c01a4d2ca7189f8c.html
科普:
Java SE=Java Standard Edition
Java EE=Java Enterprise Edition
Java ME=Java Mobile Edition
SE主要用于桌面程序,控制台开发(JFC)
EE企业级开发(JSP,EJB) 一般是开发Web应用
ME嵌入式开发(手机,小家电)
目前的JDK大致分三个大版本:
Java SE:Java Platform, Standard Edition,Java平台标准版,主要用来开发桌面程序
Java EE:Java Platform, Enterprise Edition,Java平台企业版,主要用来开发WEB程序
Java ME:Java Platform, Micro Edition,Java平台微缩版,主要用来开发移动程序
如果你已经写了servlet,估计就是一直在用Java EE技术,也许你没有使用Oracle提供的官方的Java EE SDK
在Java的中间发展阶段,曾经把上面的名字叫做J2SE、J2EE、J2ME
其中的2读作英语two,剩下的按照字母发音,2代表第二代的意思
我真的想报警了,几个小时过去了,JDK也重装了,但是还是没有解决问题:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure: Compilation failure:
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[6,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[7,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[8,17] 程序包org.junit不存在
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[28,10] 找不到符号
[ERROR] 符号: 类 Before
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[35,10] 找不到符号
[ERROR] 符号: 类 After
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[42,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[54,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[73,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] /E:/Java Work/Java Source/Spring_Struts_HibernateWebProject/src/main/java/com/test/test/TestSpringCase.java:[85,10] 找不到符号
[ERROR] 符号: 类 Test
[ERROR] 位置: 类 com.test.test.TestSpringCase
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Spring_Struts_HibernateWebProject: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有一位网友的回答比较含蓄但是很有用,他的解决办法是这样的:
我在这里用截图的方式表达一下:
首先你在Eclipse中导入你的JRE:
但是这个也不是主要的问题,也有可能是由于编码问题导致的。以下的这两个编码都应该注意:
这个问题先告一段落吧,可能有点乱,但是这是我解决问题的思路,假如能对大家有所帮助当然不胜荣幸。