Grails和Maven集成(Grails and Maven Integration)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
Grails和Maven集成(Grails and Maven Integration)

我正在尝试为现有的grails项目制作Grails和Maven Integration。 但它正在抛出异常

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>

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>

最满意答案

使用Grails 2.1.0重新编写了maven集成,现在还需要在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>

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>

更多推荐

本文发布于:2023-04-24 20:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b6603f67ad9853697170122e17a4472c.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Grails   Maven   Integration

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!