在 Grails 中,命令“tomcat:deploy”不会像命令“dev war”那样生成完整的战争

2024-03-24

命令“grails dev war”完美部署在我的本地 Tomcat6 服务器中,生成了一个包含以下文件夹的战争:

css
images
js
META-INF
plugins
WEB-INF

不幸的是,我需要该命令tomcat:部署也有效(我实际上正在使用:tomcat:redeploy -DskipTests)。但是雄猫给出下一个错误:

2013-05-23 05:12:53,094 [http-8080-4] ERROR digester.Digester  - Parse Fatal Error at line 1 column 1: Final de archivo prematuro.
org.xml.sax.SAXParseException; systemId: jndi:/localhost/Alojamiento/WEB-INF/web.xml; lineNumber: 1; columnNumber: 1; Final de archivo prematuro.
    at

我添加了一个空 web.xml以便maven编译。生成的战争中也是空的。所以这可能是问题的原因(“grails dev war”生成带有代码的web.xml)。此外,生成的战争仅包含以下文件夹:

META-INF
WEB-INF

为了能够使用“tomcat部署”,我将下一个代码添加到pom.xml中(添加pom true后,运行“create-pom group”和其他配置更改):

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <url>http://127.0.0.1:8080/manager</url>                    
        <server>TomcatServer</server>
    </configuration>
</plugin>

UPDATE 1我的完整 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>alojamiento.ingenierosIW</groupId>
    <artifactId>Alojamiento</artifactId>
    <packaging>war</packaging>
    <version>0.1</version>
    <name>Alojamiento</name>
    <description>Alojamiento</description>

    <properties>
        <grails.version>2.2.2</grails.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-dependencies</artifactId>
            <version>${grails.version}</version>
            <type>pom</type>
        </dependency>


        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-test</artifactId>
            <version>${grails.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-plugin-testing</artifactId>
            <version>${grails.version}</version>
            <scope>test</scope>
        </dependency>


    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
        <scope>runtime</scope>

    </dependency>


        <dependency>
            <groupId>org.grails.plugins</groupId>
            <artifactId>tomcat</artifactId>
            <version>${grails.version}</version>
            <scope>provided</scope>
            <type>zip</type>
        </dependency>

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


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>cache</artifactId>
        <version>1.0.1</version>
        <scope>compile</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>resources</artifactId>
        <version>1.2.RC2</version>
        <scope>runtime</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>db-reverse-engineer</artifactId>
        <version>0.5</version>
        <scope>runtime</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>jquery</artifactId>
        <version>1.8.3</version>
        <scope>runtime</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>database-migration</artifactId>
        <version>1.3.2</version>
        <scope>runtime</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>hibernate</artifactId>
        <version>2.2.2</version>
        <scope>runtime</scope>
        <type>zip</type>
    </dependency>


    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>tomcat</artifactId>
        <version>2.2.2</version>
        <scope>provided</scope>
        <type>zip</type>
    </dependency>



    </dependencies>

    <build>
        <pluginManagement />

        <plugins>
            <!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>surefire-it</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>plugins</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.grails</groupId>
                <artifactId>grails-maven-plugin</artifactId>
                <version>${grails.version}</version>
                <configuration>
                    <!-- Whether for Fork a JVM to run Grails commands -->
                    <fork>true</fork>
                </configuration>
                <extensions>true</extensions>
            </plugin>


             <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <!--<ignorePackaging>true</ignorePackaging>-->
                    <addContextWarDependencies>true</addContextWarDependencies>
                    <url>http://127.0.0.1:8080/manager</url>                    
                    <server>TomcatServer</server>
                    <!--<username>admin</username>-->
                    <!-- <password>password</password>-->
                    <!-- <path>/u74937912-practica-WAR</path>-->
                </configuration>
          </plugin>


        </plugins>
    </build>

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

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

它与此完美配合:

配置

以前,如果您使用带有 m2e 插件的 Eclipse,这里解释了如何配置 Eclipse 以便与 Tomcat 一起使用:tomcat-maven-plugin:服务器返回 HTTP 响应代码:403 https://stackoverflow.com/questions/15858436/tomcat-maven-plugin-server-returned-http-response-code-403

现在,我们需要在 C:\Users\user.m2 中有一个正确的 settings.xml,其用户和密码与 tomcat-users.xml 相同。然后,我们需要有我们的pom.xml配置如下:

<packaging>war</packaging>


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
    <url>http://127.0.0.1:8080/manager</url>   
    <!-- The next server must be the same than the one in settings.xml (at C:\Users\user\.m2): -->
    <server>TomcatServer</server>
</configuration>
</plugin>   


<plugin>
    <groupId>org.grails</groupId>
    <artifactId>grails-maven-plugin</artifactId>
    <version>${grails.version}</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>

Maven 部署命令:

下一个命令从 datasource.groovy - 生产环境获取数据库的配置值:

  • tomcat:重新部署
  • tomcat:重新部署-DskipTests
  • grails:war tomcat:重新部署 -DskipTests

要从开发环境获取值,命令如下:

  • grails:war tomcat:redeploy -Dgrails.env=development grails:war
  • tomcat:重新部署-Dgrails.env =开发-DskipTests

注意1:如果我们不添加-DskipTests(在部署之前不运行测试),并且某些测试失败,则不会部署。

注意2:在 eclipse 中(安装了 maven 插件 m2e),您必须在下一个字段中输入以下命令:

  • 运行 - 运行配置 - Maven 构建 - 目标

UPDATE 1

不要忘记在 src/main/webapp/WEB-INF 下创建一个空的 web.xml!

UPDATE 2

不要忘记告诉 Grails 使用 pom.xml:http://grails.org/doc/2.3.x/ref/Command%20Line/create-pom.html http://grails.org/doc/2.3.x/ref/Command%20Line/create-pom.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Grails 中,命令“tomcat:deploy”不会像命令“dev war”那样生成完整的战争 的相关文章

  • 如何在 Grails Geb/Spock 测试用例中获取 sessionFactory?

    我想我需要在 GebSpec 测试中刷新 hibernate 会话 所以我想获取 sessionFactory 看起来应该被注入 但是当我做这样的事情时 class MySpec extends GebSpec def sessionFac
  • 45000 ms 内无法绑定锁定端口 70 54

    当我尝试使用 MVN 测试命令行运行我的 selenium 测试时 出现此错误 奇怪的是 我三天前尝试了一下 运行成功了 T E S T S Running GoogleNavigationTest Tests run 1 Failures
  • Java:枚举:NoClassDefFoundError

    我在 J2EE 应用程序中使用枚举时遇到问题 我在无状态服务 bean 内的 switch case 中使用枚举 在运行时 我在 switch 语句上看到以下异常 Caused by java lang NoClassDefFoundErr
  • Maven:从构建中排除测试

    我在项目的 src test java 文件夹中有一些类用作测试 当我使用标准 Maven 编译插件运行 Maven 时 这些项目被编译成 class 文件 并包含在打包编译代码的 jar 中 在运行 Maven 和构建我的版本之前 我已经
  • Maven 版本插件跳过更新检查

    当我尝试使用versions use releases我的发布存储库被标记为 已禁用 这意味着快照依赖项不会解析为发布 我不明白为什么存储库被认为是禁用的 以下是构建的简短调试输出 DEBUG f remoteArtifactReposit
  • java.lang.IllegalStateException - 提交响应后无法创建会话

    我在我的项目中使用 JSF PrimeFaces 我为此准备了一个Maven项目 当我编译项目并加载主页后 我收到以下异常 java lang IllegalStateException Cannot create a session af
  • 更改 Jenkins 云构建的 gradle 本地存储库缓存位置

    我需要更改存储库下载的保存位置 我无法使用用户主目录 因为我的构建是在云服务上运行的 该服务不保留此内容 这导致我的依赖项被一遍又一遍地下载 并消耗了大量的云存储时间 我正在使用 gradle 1 0 里程碑 5 我的构建文件具有以下存储库
  • Docker 和 Eureka 与 Spring Boot 无法注册客户端

    我有一个使用 Spring Boot Docker Compose Eureka 的非常简单的演示 我的服务器在端口 8671 上运行 具有以下应用程序属性 server port 8761 eureka instance prefer i
  • 如何从引用的java项目访问静态资源(WEB-INF)文件夹中的文件?

    我有一个 Web 应用程序 其中包含一个作为 spring bean 公开的应用程序服务之一的配置 xml 文件 另外 我在同一工作区中有一个独立的 java 应用程序 它从其 pom xml 引用我的 Web 应用程序项目 它使用 Spr
  • Swagger for Micronaut 与 Maven

    我想从 Spring Boot 2 切换到 Micronaut 框架 而且我在 Swagger 设置上遇到了困难 在 Spring Boot 2 项目中 我有以下依赖项
  • 每个组织的 Spring Security 用户角色

    在我的应用程序中 我有一个名为组织的顶级实体 用户和组织之间的关系是多对多的 因此 我可能会遇到以下情况 用户拥有组织的角色 ROLE ADMIN 用户拥有组织的角色 ROLE USER 我需要确保当用户 A 访问 Organization
  • Grails 2.3.0 自动重新加载不起作用

    我最近将我们的项目升级到 grails 2 3 0 一切工作正常 除了每当我更改代码时自动重新加载都无法工作的问题 这包括所有项目工件 控制器 域 服务 gsps css 和 javascript 文件 我的旧版本 grails 可以正常工
  • eclipse中导入项目文件夹图标

    我在 Eclipse 工作区中新导入的 Maven 项目有J and M项目文件夹顶部的图标 项目和包资源管理器 而其他导入的 Maven 项目只有一个J icon 有人可以解释其中的区别吗 该项目有J装饰器被称为 Java 项目和具有M装
  • 适合 .Net 开发人员的 Grails/Roo

    我目前正在学习 Grails 和 Roo 绝大多数培训材料都是针对新开发人员或现有 Java 开发人员 有谁知道使用 Net C ASP Net Asp Net MVC 翻译现有开发经验的任何指南 资源或技巧 你做过很多 ASP MVC 吗
  • JSF Maven Mojarra 实施

    我尝试使用 JSF Eclipse 和 Maven 创建简单的项目 我用了
  • 使用 JQuery 的 Grails 项目,无需插件

    我正在尝试设置一个简单的 Grails 2 1 1 应用程序 该应用程序将使用 JQuery 我有一个名为 TestController 的控制器和一个位于正确位置的index gsp 我手动添加 JQuery 库 没有使用 Grails
  • com.google.android:android:jar 的 dependency.dependency.version' 丢失

    我正在尝试使用 Eclipse 运行一个简单的虚拟 Android 项目 并且我正在尝试使用 Maven amd 我已按照已接受答案的教程进行操作this https stackoverflow com questions 6735562
  • 将 hyperjaxb3 升级到 jpa 2.1

    我正在尝试在使用 maven jpa hibernate 和 hyperjaxb 的 eclipse 项目中升级到 JPA 2 1 当我尝试执行以下操作时出现以下错误Run As Run on Server从日食内部 java lang N
  • 由于 maven-surefire-plugin,Maven 构建失败

    我这里有类似的问题eclipse 中缺少 maven surefire plugin https stackoverflow com questions 23588957 maven surefire plugin missing in e
  • Maven 插件前缀解析如何工作?为什么它解决了“findbugs”而不是“jetty”?

    我正在使用 Maven 进行一些测试 并意识到我可以执行findbugsFindbugs 插件的目标 无需将插件添加到 POM 文件 另一方面 当我需要运行runJetty 插件的目标 我被迫将插件添加到 POM 文件中 否则构建失败 为什

随机推荐