与maven奇怪的编译问题

时间:2013-05-06 17:24:24

标签: java maven ubuntu

我有一个Java项目,只能在Mac上编译(OS-X Mountain Lion)。当我尝试在Ubuntu机器上编译同一个项目时,它失败了。

基本上它抱怨它无法找到一个班级。但是,该类存在于maven类路径中。我使用mvn开关运行-X后验证了该问题。

(see     612 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-twitter/2.11.0/camel-twitter-2.11.0.jar ) below. 

我甚至删除了我的$ HOME / .m2存储库,以便它再次下载所有内容。但它仍然失败。

知道我在这里缺少什么吗?

这是我在Ubuntu上的环境。

mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_32, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_32/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-40-generic", arch: "amd64", family: "unix"

感谢。

UPDATE(在我的Java类中添加导入) 我的Java类中的导入(src / main / java /...)

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.twitter.TwitterComponent;
import org.apache.camel.component.websocket.WebsocketComponent;

这是堆栈跟踪。

629 [ERROR] /tmp/jettycamelwebsocket/src/main/java/demo/websocket/TwitterStreamRoute.java:[27,55] incompatible types
630 [ERROR] found   : org.apache.camel.Component
631 [ERROR] required: org.apache.camel.component.twitter.TwitterComponent
632 [ERROR]
633 [ERROR] /tmp/jettycamelwebsocket/src/main/java/demo/websocket/TwitterStreamRoute.java:[33,8] fromF(java.lang.String,java.lang.Object...    ) in org.apache.camel.builder.RouteBuilder cannot be applied to (java.lang.String,java.lang.String,java.lang.String)
634 [ERROR] -> [Help 1]
635 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:com    pile (default-compile) on project jettycamelwebsocket: Compilation failure
636         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
637         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
638         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
639         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
640         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
641         at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
642         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
643         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
644         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
645         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
646         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
647         at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
648         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
649         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
650         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
651         at java.lang.reflect.Method.invoke(Method.java:597)
652         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
653         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
654         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
655         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
656 Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
657         at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
658         at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
659         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
660         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
661         ... 19 more

以下是显示类路径的输出。

$mvn -X clean install 


583 [DEBUG] Output directory: /tmp/jettycamelwebsocket/target/classes
584 [DEBUG] Classpath:
585 [DEBUG]  /tmp/jettycamelwebsocket/target/classes
586 [DEBUG]  /home/c/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
587 [DEBUG]  /home/c/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar
588 [DEBUG]  /home/c/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
589 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-core/3.2.2.RELEASE/spring-core-3.2.2.RELEASE.jar
590 [DEBUG]  /home/c/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
591 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-web/3.2.2.RELEASE/spring-web-3.2.2.RELEASE.jar
592 [DEBUG]  /home/c/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
593 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-aop/3.2.2.RELEASE/spring-aop-3.2.2.RELEASE.jar
594 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-beans/3.2.2.RELEASE/spring-beans-3.2.2.RELEASE.jar
595 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-context/3.2.2.RELEASE/spring-context-3.2.2.RELEASE.jar
596 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-webmvc/3.2.2.RELEASE/spring-webmvc-3.2.2.RELEASE.jar
597 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-expression/3.2.2.RELEASE/spring-expression-3.2.2.RELEASE.jar
598 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-spring/2.11.0/camel-spring-2.11.0.jar
599 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-server/8.1.3.v20120416/jetty-server-8.1.3.v20120416.jar
600 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
601 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.3.v20120416/jetty-continuation-8.1.3.v20120416.jar
602 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-servlet/8.1.3.v20120416/jetty-servlet-8.1.3.v20120416.jar
603 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-security/8.1.3.v20120416/jetty-security-8.1.3.v20120416.jar
604 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-servlets/8.1.3.v20120416/jetty-servlets-8.1.3.v20120416.jar
605 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-client/8.1.3.v20120416/jetty-client-8.1.3.v20120416.jar
606 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-util/8.1.3.v20120416/jetty-util-8.1.3.v20120416.jar
607 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-webapp/8.1.3.v20120416/jetty-webapp-8.1.3.v20120416.jar
608 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-xml/8.1.3.v20120416/jetty-xml-8.1.3.v20120416.jar
609 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-http/8.1.3.v20120416/jetty-http-8.1.3.v20120416.jar
610 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-io/8.1.3.v20120416/jetty-io-8.1.3.v20120416.jar
611 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-core/2.11.0/camel-core-2.11.0.jar
612 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-twitter/2.11.0/camel-twitter-2.11.0.jar
613 [DEBUG]  /home/c/.m2/repository/org/twitter4j/twitter4j-core/3.0.3/twitter4j-core-3.0.3.jar
614 [DEBUG]  /home/c/.m2/repository/org/twitter4j/twitter4j-stream/3.0.3/twitter4j-stream-3.0.3.jar
615 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-websocket/2.11.0/camel-websocket-2.11.0.jar
616 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-websocket/7.6.8.v20121106/jetty-websocket-7.6.8.v20121106.jar
617 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-jmx/7.6.8.v20121106/jetty-jmx-7.6.8.v20121106.jar

1 个答案:

答案 0 :(得分:2)

我知道了。我不得不将这个插件添加到我的pom.xml中的插件中。我仍然不确定为什么它适用于OS-X而不是Ubuntu。

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.3.2</version>
                        <configuration>
                                <source>1.6</source>
                                <target>1.6</target>
                        </configuration>
                </plugin>