【问题标题】:Grails acegi plugin classes not added to mavenGrails acegi 插件类未添加到 Maven
【发布时间】:2011-01-05 11:15:30
【问题描述】:

我使用 acegi 插件 0.5.2 创建了一个 grails 1.2.0 项目,效果非常好。

要将项目集成到我们的公司构建基础架构中,我需要通过 maven 构建它。因此,我使用 grails maven integration 将它转换为一个 maven 项目,该项目也运行良好。

有一个问题:我有一个实现 GrailsUser 接口的 Java 类 CustomUserDetails。当 maven 尝试编译项目时,它找不到 GrailsUser 接口类,它是 acegi 插件 的一部分。

是我遗漏了什么还是 grails maven 集成有问题导致类路径中缺少插件类?

更新:这是我项目的 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.troii</groupId>
  <artifactId>testapp</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-crud</artifactId>
      <version>1.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-gorm</artifactId>
      <version>1.2.0</version>
    </dependency>

    <!-- Grails defaults to Ehache for the second-level Hibernate cache. -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>3.3.1.GA</version>
    </dependency>
    <dependency>
      <groupId>javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.11.0.GA</version>
    </dependency>

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>1.7.1</version>
      <exclusions>
          <exclusion>
              <artifactId>jms</artifactId>
          </exclusion>
          <exclusion>
              <artifactId>servlet-api</artifactId>
          </exclusion>

          <!-- We have JCL-over-SLF4J instead. -->
          <exclusion>
              <artifactId>commons-logging</artifactId>
          </exclusion>
      </exclusions>
    </dependency>

    <!-- For ease of development and testing, we include the HSQLDB database. -->
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>1.8.0.10</version>
    </dependency>

    <!-- Use Log4J for logging. This artifact also pulls in the Log4J JAR. -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>

  <repositories>
    <!-- Required to get hold of JTA -->
    <repository>
      <id>maven2-repository.dev.java.net</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2/</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>Codehaus Snapshots</id>
      <url>http://snapshots.repository.codehaus.org</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>Codehaus Snapshots</id>
      <url>http://snapshots.repository.codehaus.org</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <pluginManagement />
    <plugins>
      <plugin>
        <groupId>org.grails</groupId>
        <artifactId>grails-maven-plugin</artifactId>
        <version>1.2.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>init</goal>
              <goal>maven-clean</goal>
              <goal>validate</goal>
              <goal>config-directories</goal>
              <goal>maven-compile</goal>
              <goal>maven-test</goal>
              <goal>maven-war</goal>
              <goal>maven-functional-test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>tools</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>${java.version}</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>

【问题讨论】:

  • 你能把 pom.xml 文件贴出来吗?

标签: grails maven spring-security


【解决方案1】:

我认为您希望在编译项目源代码时可以使用插件类路径。插件有自己的类加载器,所以你的类不会看到里面的东西。

改为将项目依赖项定义为包含 GrailsUser 接口的库,并确保该依赖项的范围是 compile(默认)。

【讨论】:

  • 是的,我虽然是这样的原因,但我不确定这是一个错误还是我需要做一些不同的事情。你知道是否有一个包含 acegi 插件类的 maven 工件?
  • 这样的东西有用吗? mvn grails:install-plugin -DpluginName=acegi mvn initialize 更多信息在这里:grails.org/Maven+Integration我上面没有测试过
  • 不,这会安装 grails 插件,但不会更改 maven 依赖项
猜你喜欢
  • 1970-01-01
  • 2010-12-11
  • 2011-09-06
  • 2011-05-28
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多