Maven编译提示:软件包不存在

来源:互联网 发布:舆情分析研判数据 编辑:程序博客网 时间:2024/05/17 15:20

eclipse下建立的java maven项目,

copy一段别人的pom的dependency到本项目pom,编译报错如下:


[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.179 s
[INFO] Finished at: 2015-05-22T10:21:47+08:00
[INFO] Final Memory: 19M/158M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project spring-batch-admin-sample: Compilation failure: Compilation failure:
[ERROR] /D:/Workspace/spring-batch-admin-sample/src/main/java/com/lz/act/batch/support/JobTasklet.java:[7,17] D:\Workspace\spring-batch-admin-sample\src\main\java\com\lz\act\batch\support\JobTasklet.java:7: 软件包 org.slf4j 不存在
[ERROR] /D:/Workspace/spring-batch-admin-sample/src/main/java/com/lz/act/batch/support/JobTasklet.java:[8,17] D:\Workspace\spring-batch-admin-sample\src\main\java\com\lz\act\batch\support\JobTasklet.java:8: 软件包 org.slf4j 不存在
[ERROR] /D:/Workspace/spring-batch-admin-sample/src/main/java/com/lz/act/batch/support/JobTasklet.java:[34,30] D:\Workspace\spring-batch-admin-sample\src\main\java\com\lz\act\batch\support\JobTasklet.java:34: 找不到符号
[ERROR] 符号: 类 Logger
[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-batch-admin-sample: 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:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:46)
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:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 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


检查maven library,jar包是有的,估计是依赖问题。

由于新建的project有parent ,再看parent  pom,发现也引用了org.slf4j 。

解决办法:



1、去掉dependency的runtime,或改成compile试试

   <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <scope>runtime</scope>
   </dependency>

2、dependency去掉对软件包 org.slf4j 的依赖,自动继承parent的依赖。





0 0
原创粉丝点击