【问题标题】:Error Messages after updating Project Configuration via Maven通过 Maven 更新项目配置后的错误消息
【发布时间】:2011-12-06 09:52:36
【问题描述】:

我正在使用 Maven 开发一个项目。过了一会儿,我在我的 IDE(Springsource 工具套件)中“更新了项目配置”。现在我的 IDE 抱怨说有一些以前没有出现过的错误。 奇怪的是,错误消息似乎是错误的。在下面的代码中,它说我必须删除@override 注释,因为必须重写超类(我实际上在做什么?)

 package org.powertac.humanbroker.services;

        import javax.jms.JMSException;
        import javax.jms.Message;
        import javax.jms.MessageListener;
        import javax.jms.TextMessage;            
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;

    public class JMSMessageListenerDecorator  implements MessageListener{

        private static final Logger Log =     LoggerFactory.getLogger(JMSMessageListenerDecorator.class);
        private BaseMessageListener messageListener = null;

        public JMSMessageListenerDecorator(BaseMessageListener l){
            messageListener = l;
        }

        @Override
        public void onMessage(Message message) {

            if (message instanceof TextMessage) {
                try {                               
                    if(Log.isDebugEnabled())
                        Log.debug("Received message "+ message.toString()+" from JMS.");

                    messageListener.onMessage(((TextMessage) message).getText());
                } catch (Exception e){ 
                    Log.error ("The original message leading up to the exception reads ${message.text}.", e);
                }
            } else {
                Log.error ("The JMS Listener knows only how to react to TextMessage objects.");
            }

        }

    }

知道我可以做些什么来使错误消息消失吗?谢谢

PS:我在 3 个不同的类中收到了大约 5 条错误消息,并且都抱怨 @Override 注释。


更新

我的 pom.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>xyz</artifactId>
  <name>xyz</name>
  <description>xyz</description>
  <repositories>
      <repository>  
        <id>prime-repo</id>  
        <name>PrimeFaces Maven Repository</name>  
        <url>http://repository.primefaces.org</url>  
        <layout>default</layout>  
    </repository>  
  </repositories>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-faces</artifactId>
        <version>${springwebflow-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${springsecurity-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${springsecurity-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${springsecurity-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <!-- Communication to  Server -->

      <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
      <groupId>com.thoughtworks.xstream</groupId>
      <artifactId>xstream</artifactId>
      <version>1.4.1</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>javax.jms</groupId>
    <artifactId>jms-api</artifactId>
    <version>1.1-rev-1</version>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.5.1</version>
</dependency>
<dependency>
    <groupId>activecluster</groupId>
    <artifactId>activecluster</artifactId>
    <version>20040423.075722</version>
</dependency>
<dependency>
    <groupId>xmlbeans</groupId>
    <artifactId>xbean</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>javacc</groupId>
    <artifactId>javacc</artifactId>
    <version>4.0</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jms</artifactId>
    <version>3.0.6.RELEASE</version>
</dependency>
<dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.1</version>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.ws.rs</groupId>
    <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
    <version>1.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.jdom</groupId>
    <artifactId>jdom</artifactId>
    <version>1.1.2</version>
</dependency>
<dependency>
    <groupId>jaxen</groupId>
    <artifactId>jaxen</artifactId>
    <version>1.1.3</version>
    <!-- http://jira.codehaus.org/browse/JAXEN-217 -->
    <exclusions>
      <exclusion>
        <groupId>maven-plugins</groupId>
        <artifactId>maven-cobertura-plugin</artifactId>
      </exclusion>
      <exclusion>
        <groupId>maven-plugins</groupId>
        <artifactId>maven-findbugs-plugin</artifactId>
      </exclusion>
    </exclusions>
</dependency>


    <!-- Sun Mojarra JSF 2 runtime -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.0.3</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.0.2.GA</version>
    </dependency>
      <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-core</artifactId>
       <version>3.3.2.GA</version>
    </dependency>
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-annotations</artifactId>
       <version>3.4.0.GA</version>
    </dependency>
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-commons-annotations</artifactId>
       <version>3.3.0.ga</version>
    </dependency>
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-entitymanager</artifactId>
       <version>3.4.0.GA</version>
    </dependency> 
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.ejb</groupId>
        <artifactId>ejb-api</artifactId>
        <version>3.0</version>
    </dependency>
        <!-- PrimeFaces component library -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.powertac</groupId>
        <artifactId>server-interface</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
  <reporting>
  <plugins>
  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.5.1</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.3.3</version>
      </plugin>
      <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>
  </plugins>
  </reporting>
  <packaging>war</packaging>
  <properties>
    <springframework-version>3.0.5.RELEASE</springframework-version>
    <springwebflow-version>2.3.0.RELEASE</springwebflow-version>
    <springsecurity-version>3.0.3.RELEASE</springsecurity-version>
    <org.slf4j-version>1.5.10</org.slf4j-version>
  </properties>
  <groupId>org.powertac</groupId>
  <version>0.0.1-SNAPSHOT</version>
</project>

【问题讨论】:

  • 检查你的JDK版本,如果不是6+,你会看到这个错误

标签: java maven maven-3 sts-springsourcetoolsuite


【解决方案1】:

在你的 pom.xml 中,你会想要这样的东西:

<build>
    <plugins>
        <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>
    </plugins>
</build>

您当前的 pom.xml 可能正在为 Java 5 配置您的项目(可能是默认情况下),您正在使用 Java 6 的语言语义。如果您将所有内容都配置为 Java 6,那么您应该已准备就绪。

【讨论】:

  • hmm...我将您的代码包含在我的 pom.xml 中,并再次执行了“更新项目配置”,但不幸的是它不起作用。错误消息保持不变...
  • 您能否验证 Eclipse 认为 Java 版本设置为什么?右键单击项目,属性,Java编译器,然后在内容窗格中的“JDK合规性”下查看?如果它仍然设置为 1.5,我需要查看你的整个 pom.xml。这个 sn-p 是否可能包含在错误的位置? (它需要在 / 中。)
  • :D 有一个复选框,名为“在 Java 构建路径上使用来自执行环境 'J2SE-1.5' 的合规性”。我取消选中并手动选择“编译器合规性级别:1.6”。现在它正在工作!非常感谢!
  • 感谢您的回答,但我不认为这已解决。 “使用合规性表单执行环境”值正是应该从 Maven 设置的值。我假设您正在使用 m2e 与 Eclipse 进行 Maven 集成?如果是这样,请确保您拥有最新版本。
  • mhm...猜你是对的..我重新打开了这个问题,并将用我的 pom 文件更新我的原始帖子....
猜你喜欢
  • 1970-01-01
  • 2011-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-07
  • 2018-10-12
  • 2014-06-10
相关资源
最近更新 更多