简体   繁体   中英

Grails and Maven Integration

I am trying to make Grails and Maven Integration for existing grails project. But it is throwing exception as

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

My 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>

The maven integration was reworked with Grails 2.1.0 and plugin dependencies now also need to be defined in the Maven pom file. While previously the plugin dependencies were managed using BuildConfig.groovy or application.properties.

You need to move all plugin and regular dependencies from BuildConfig.groovy and application.properties to the pom.file.

For some plugins it might be necessary to explicitly add dependencies in the pom that were not explicitly needed using standard Grails. But this will become clear from the error logs when starting Grails with Maven.

Concretely you are missing the dependency on the Spring security plugin, and need to add the following XML fragment to your dependency list:

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

You also need to make sure the Grails maven repository is available by adding the following fragment to the pom file:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM