无法解析符号@TextIndexed并且无法解析符号TextCriteria

时间:2015-04-16 13:19:41

标签: spring spring-data-mongodb

我试图将Spring Data MongoDB的版本更改为1.6.M1,但问题仍然存在。

如何修复导入:

import org.springframework.data.mongodb.core.index.TextIndexed;

import org.springframework.data.mongodb.core.query.TextCriteria;

这是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.sab</groupId>
        <artifactId>sampleApp</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>war</packaging>
        <name>Sample App</name>
        <description>Sample App</description>

        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                <!-- Spring Framework -->
                <spring.version>3.2.0.RELEASE</spring.version>
                <spring.security.core.version>3.1.3.RELEASE</spring.security.core.version>

                <!-- Mongo DB driver & Spring Data MongoDB -->
                <spring.data.mongodb.version>1.1.1.RELEASE</spring.data.mongodb.version>

                <mongodb.driver.version>2.10.1</mongodb.driver.version>

                <!-- Java Servlet -->
                <javax.servlet-api.version>3.0.1</javax.servlet-api.version>
                <javax.jstl-taglibs.version>1.2</javax.jstl-taglibs.version>

                <!-- Miscellaneous Dependencies -->
                <jackson.version>2.1.1</jackson.version>
                <log4j.version>1.2.14</log4j.version>

                <!-- Plugins -->
                <maven.compiler.plugin.version>2.3.2</maven.compiler.plugin.version>
                <maven.war.plugin.version>2.1.1</maven.war.plugin.version>
        </properties>

        <dependencies>
                <!-- Spring Core -->
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-context</artifactId>
                        <version>${spring.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-webmvc</artifactId>
                        <version>${spring.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                        <version>${spring.version}</version>
                </dependency>

                <!-- Logger -->
                <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>${log4j.version}</version>
                        <type>jar</type>
                        <scope>compile</scope>
                </dependency>


                <!-- Javax Servlet. This needs to be included for runtime only! -->
                <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                        <version>${javax.servlet-api.version}</version>
                </dependency>
                <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>jstl</artifactId>
                        <version>${javax.jstl-taglibs.version}</version>
                </dependency>

                <!-- Jackson JSON processor -->
                <dependency>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                        <version>${jackson.version}</version>
                </dependency>
                <dependency>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                        <version>${jackson.version}</version>
                </dependency>
                <dependency>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                        <version>${jackson.version}</version>
                </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.6.0.BUILD-SNAPSHOT</version>
        </dependency>



                <!-- Spring Data MongoDB -->
         <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>${spring.data.mongodb.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <!-- MongoDB Java Driver -->
                <dependency>
                        <groupId>org.mongodb</groupId>
                        <artifactId>mongo-java-driver</artifactId>
                        <version>${mongodb.driver.version}</version>
                        <type>jar</type>
                        <scope>compile</scope>
                </dependency>

                <!-- Spring Security -->
                <dependency>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-core</artifactId>
                        <version>${spring.security.core.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-web</artifactId>
                        <version>${spring.security.core.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-config</artifactId>
                        <version>${spring.security.core.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-taglibs</artifactId>
                        <version>${spring.security.core.version}</version>
                </dependency>
        <!-- Jsoup  -->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.1</version>
        </dependency>
        </dependencies>
        <build>
                <finalName>sampleqa</finalName>

                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <version>${maven.compiler.plugin.version}</version>
                                <configuration>
                                        <source>1.6</source>
                                        <target>1.6</target>
                                </configuration>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-war-plugin</artifactId>
                                <version>${maven.war.plugin.version}</version>
                                <configuration>
                                        <failOnMissingWebXml>false</failOnMissingWebXml>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
        <repositories>
                <!-- For main Spring releases -->
                <repository>
                        <id>org.springframework.maven.release</id>
                        <name>Spring Maven Release Repository</name>
                        <url>http://maven.springframework.org/release</url>
                        <releases>
                                <enabled>true</enabled>
                        </releases>
                        <snapshots>
                                <enabled>false</enabled>
                        </snapshots>
                </repository>
                <!-- For Java Releases -->
                <repository>
                        <id>java.net2</id>
                        <name>Repository hosting the jee6 artifacts</name>
                        <url>http://download.java.net/maven/2</url>
                </repository>
                <repository>
                        <id>jboss</id>
                        <name>JBoss repository</name>
                        <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
                </repository>
        </repositories>
</project>

1 个答案:

答案 0 :(得分:0)

如果我没错,你的编译器就会在这一行上给出错误

import org.springframework.data.mongodb.core.index.TextIndexed;

但是这个类存在于以下路径

\spring-data-mongodb-1.6.0.RELEASE.jar.zip\org\springframework\data\mongodb\core\index

要解决此问题,请在您的类路径中检查此jar spring-data-mongodb-1.6.0.XXXX是否存在。 如果它的当前解压缩并检查该类是否存在。

如果有类那么检查你的类路径中的任何其他jar是否具有相同的名称并且具有不同的版本,如果它只是从类路径中删除它并检查编译问题。

最好有一个干净的部署有时旧的jar不会从类路径中删除由于外部访问问题可能会导致问题。