1

我正在尝试为现有的 grails 项目进行 Grails 和 Maven 集成。但它抛出异常

maven-test (default) on project Co-optimum: Unable to start Grails:    java.lang.reflect.InvocationTargetException: org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint: org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint

我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.samples</groupId>
    <artifactId>Co-optimum</artifactId>
    <packaging>war</packaging>
    <name>Co-optimum</name>
    <properties>
        <sourceComplianceLevel>1.6</sourceComplianceLevel>
    </properties>
    <version>0.1</version>

    <dependencies>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    <build>

        <plugins>

            <plugin>
                <groupId>org.grails</groupId>
                <artifactId>grails-maven-plugin</artifactId>
                <version>1.3.7</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>clean</goal>
                            <goal>config-directories</goal>
                            <goal>maven-compile</goal>
                            <goal>maven-test</goal>
                            <goal>maven-war</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
4

1 回答 1

4

Grails 2.1.0 对 Maven 集成进行了重新设计,现在还需要在 Maven pom 文件中定义插件依赖项。以前,插件依赖项是使用 BuildConfig.groovy 或 application.properties 管理的。

您需要将所有插件和常规依赖项从 BuildConfig.groovy 和 application.properties 移动到 pom.file。

对于某些插件,可能需要在 pom 中显式添加使用标准 Grails 未显式需要的依赖项。但这会在使用 Maven 启动 Grails 时从错误日志中变得清楚。

具体来说,您缺少对 Spring 安全插件的依赖项,需要将以下 XML 片段添加到您的依赖项列表中:

       <dependency>
            <groupId>org.grails.plugins</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>1.2.7.3</version>
            <scope>compile</scope>
            <type>zip</type>
        </dependency>

您还需要通过将以下片段添加到 pom 文件来确保 Grails maven 存储库可用:

<repositories>
    <repository>
        <id>grails</id>
        <name>grails</name>
        <url>http://repo.grails.org/grails/core</url>
    </repository>
    <repository>
        <id>grails-plugins</id>
        <name>grails-plugins</name>
        <url>http://repo.grails.org/grails/plugins</url>
    </repository>
</repositories>
于 2012-08-14T12:30:57.080 回答