0

我试图从下面的链接创建一个基本的气氛测试。我已经从 pom 文件中下载了它所要求的所有内容。但由于某种原因,日食无法识别“@MeteorService(path = "/*", interceptors = {AtmosphereResourceLifecycleInterceptor.class})”

https://github.com/Atmosphere/atmosphere/blob/master/samples/meteor-chat/src/main/java/org/atmosphere/samples/chat/MeteorChat.java

有任何想法吗?我用的是大气0.9.7版本

Maven 安装

=======================
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building atmosphere-meteor-chat 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ atmosphere-meteor-chat ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ atmosphere-meteor-chat ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to Q:\myEdu\atmosphere-meteor-chat\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] \myEdu\atmosphere-meteor-chat\src\main\java\org\atmosphere\samples\chat\MeteorChat.java:[31,1] cannot find symbol
symbol: class MeteorService
@MeteorService(path = "/*", interceptors = {AtmosphereResourceLifecycleInterceptor.class})
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.542s
[INFO] Finished at: Tue Jul 24 23:10:57 EDT 2012
[INFO] Final Memory: 7M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project atmosphere-meteor-chat: Compilation failure
[ERROR] \myEdu\atmosphere-meteor-chat\src\main\java\org\atmosphere\samples\chat\MeteorChat.java:[31,1] cannot find symbol
[ERROR] symbol: class MeteorService
[ERROR] @MeteorService(path = "/*", interceptors = {AtmosphereResourceLifecycleInterceptor.class})
[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

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>
    <groupId>org.atmosphere.samples</groupId>
    <artifactId>atmosphere-meteor-chat</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>atmosphere-meteor-chat</name>
        <properties>
        <atmosphere.version>0.9.7</atmosphere.version>
        <jersey.version>1.10</jersey.version>
        <nettosphere.version>1.3.1</nettosphere.version>
        <ahc.version>1.7.4</ahc.version>
        <javaee.version>6.0</javaee.version>
        <testng.version>6.5.2</testng.version>
        <logback.version>1.0.6</logback.version>
        <maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
        <maven-war-plugin.version>2.1.1</maven-war-plugin.version>
        <jetty.version>8.1.1.v20120215</jetty.version>
    </properties>
    <repositories>
        <repository>
            <id>Sonatype snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
        <repository>
            <id>Sonatype releases</id>
            <url>https://oss.sonatype.org/content/repositories/releases</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-jquery</artifactId>
            <version>${atmosphere.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>${atmosphere.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>
          <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <!-- This is ONLY required if you use Atmosphere's annotation -->
        <dependency>
            <groupId>eu.infomas</groupId>
            <artifactId>annotation-detector</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-servlet_3.0_spec</artifactId>
            <version>1.0</version>
            </dependency>
    </dependencies>
</project>
4

2 回答 2

2

MeteorService 在大气运行时版本 1.1.0-SNAPSHOT 中,因此将 0.9.7 更改为 1.1.0-SNAPSHOT 应该修复它。

我还找到了 m2e-apt Eclipse 插件来帮助注释来自 Maven 稳定更新站点http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt

于 2012-09-22T00:52:14.740 回答
1

确保你的 pom.xml 中有:

    <dependency>
        <groupId>eu.infomas</groupId>
        <artifactId>annotation-detector</artifactId>
        <version>3.0.0</version>
    </dependency>

您应该在日志中看到:

6:31:48.712 [main] INFO o.atmosphere.cpr.AtmosphereFramework - Atmosphere 正在使用 org.atmosphere.cpr.DefaultAnnotationProcessor 处理注释 06:31:48.721 [main] INFO oacpr.DefaultAnnotationProcessor - 在 org.atmosphere 中找到注释。正在扫描的 samples.chat.MeteorChat:接口 org.atmosphere.config.service.MeteorService 06:31:48.729 [main] INFO o.atmosphere.cpr.AtmosphereFramework - 安装的 AtmosphereHandler org.atmosphere.handler.ReflectorServletProcessor 映射到上下文路径: /* 06:31:48.729 [main] INFO o.atmosphere.cpr.AtmosphereFramework - 安装的 AtmosphereInterceptor [Atmosphere LifeCycle] 映射到 AtmosphereHandler org.atmosphere.handler.ReflectorServletProcessor

谢谢

——让弗朗索瓦

于 2012-07-24T10:32:39.430 回答