IT序号网

grails之Grails和Maven集成

lvdongjie 2025年12月25日 编程语言 23 0

我正在尝试将Grails和Maven集成到现有的grails项目中。
但这引发了异常

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> 

请您参考如下方法:

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

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

对于某些插件,可能需要使用标准Grails在pom中显式添加不需要的依赖项。但是从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> 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!