带有maven-plugin的Scala无法找到依赖项

时间:2012-03-22 00:53:11

标签: spring scala maven

我有一个使用maven的scala项目。当我只使用scala类时,maven插件没有问题。 但现在,我在尝试编译时遇到错误:

[警告] C:\ java \ workspace \ mcare \ src \ main \ scala \ com \ fb \ mcare \ config \ AppConfig.scala:2:错误:对象springframework不是包org的成员 [警告]导入org.springframework.context.annotation.Configuration

package com.fb.mcare.config
import org.springframework.context.annotation.Configuration

@Configuration
class AppConfig {

}

我的pom:

http://maven.apache.org/maven-v4_0_0.xsd“>     4.0.0     com.fb     mcare     0.0.1-SNAPSHOT     2008年              2.9.1-1         3.1.0.RELEASE          战争                           scala-tools.org             Scala-Tools Maven2存储库             http://scala-tools.org/repo-releases                               com.springsource.repository.maven.release             http://maven.springframework.org/release/                              假                           

<pluginRepositories>
    <pluginRepository>
        <id>scala-tools.org</id>
        <name>Scala-Tools Maven2 Repository</name>
        <url>http://scala-tools.org/repo-releases</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.specs</groupId>
        <artifactId>specs</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-servlet_3.0_spec</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.9.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <executions>
                <execution>
                    <id>scala-compile-first</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>scala-test-compile</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

几乎尝试了一切,我在这里缺少什么?

此致

1 个答案:

答案 0 :(得分:5)

尝试从pom.xml中的spring-context依赖项中删除<scope>runtime</scope>。运行时范围依赖项不包含在编译时类路径中。有关各种范围的详细信息,请参阅http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html