当前位置: 首页 > 知识库问答 >
问题:

Maven Tomcat部署配置文件插件

岳毅
2023-03-14

我试图在我的项目pom中使用配置文件。xml文件,用于控制将我的war文件部署到特定服务器。例如,我有一个本地配置文件和一个开发服务器配置文件。下面是我如何设置个人资料的

<profiles>

    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <property>
                <name>target</name>
                <value>local</value>
            </property>
        </activation>
        ...
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://10.16.21.60:8080/manager/text</url>
                        <server>localTomcat</server>
                        <path>/</path>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

    <profile>
        <id>dev</id>
        <activation>
            <property>
                <name>target</name>
                <value>dev</value>
            </property>
        </activation>
        ...
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://devserverurl:8080/manager/text</url>
                        <server>devTomcat</server>
                        <path>/</path>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

我打电话来

mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy

当我尝试此操作时,我可以看到,它不是尝试连接到我的配置10.16.21.60中提供的IP地址,而是尝试连接到localhost。我在本地设置中定义了devTomcatlocalTomcat。xml包含用户名和密码的文件。

如果我然后添加-X选项,以获得更多信息,我可以在插件的调试输出中看到(强调部分已添加)

    [DEBUG] Configuring mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy from plugin realm ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
    [DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy' with basic configurator -->
    [DEBUG]   (f) charset = ISO-8859-1
    [DEBUG]   (f) contextFile = ....
    [DEBUG]   (f) ignorePackaging = false
    [DEBUG]   (f) mode = war
    [DEBUG]   (f) packaging = war
    [DEBUG]   (f) path = ...
    [DEBUG]   (f) update = false
    [DEBUG]   (f) url = http://localhost:8080/manager/text
    [DEBUG]   (f) version = 2.2
    [DEBUG]   (f) warFile =  ...
    [DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@61874b9d
    [DEBUG] -- end configuration --
    [INFO] Deploying war to http://localhost:8080/...  
    [DEBUG] No server specified for authentication - using defaults

似乎没有遵守我的配置设置!我认为这是可行的,因为local配置文件被激活,所以它将使用该配置。

我也尝试过在我的

可能值得注意的是,我也在这个项目中使用了gwt-maven-plugin,我不知道这是否会干扰tomcat插件配置。

共有1个答案

越星晖
2023-03-14

好的,原来我在插件中使用了错误的groupID。不是

<groupId>org.codehaus.mojo</groupId>

它是

<groupId>org.apache.tomcat.maven</groupId>

现在就像冠军一样!

 类似资料:
  • 插件配置文件是插件目录下的config.php,不需要配置的插件可以不添加此文件; 文件结构: return array ( 'text' => array (// 在后台插件配置表单中的键名 ,会是config[text] 'title' => '文本:', // 表单的label标题 'type' => 'text',// 表单的类型:text,pass

  • 我试图在Kubernetes集群上部署RabbitMQ,并使用initcontainer从ConfigMap复制一个文件。但是,POD处于运行状态后,文件不会复制。 最初,我尝试不使用init容器,但我得到了一个错误,如“触摸:不能触摸'/etc/Rabbitmq/rabbitmq.conf':只读文件系统” 文件“definitions.json”应复制到/etc/reabbitmq文件夹。我遵

  • 但却被忽略了。 是否可以使用maven激活配置文件?

  • 问题内容: 我一直在开发一些Node应用程序,并且一直在寻找一种存储与部署相关的设置的良好模式。在Django世界(我来自哪里)中,通常的做法是创建一个包含标准设置(时区等)的文件,然后包含一个用于部署特定设置的文件。与哪个数据库进行通信,什么Memcache套接字,管理员的电子邮件地址等等。 我一直在寻找Node的类似模式。只需一个配置文件就可以了,因此它不必与中的其他所有文件一起使用,但是我发

  • 我试图使用maven shade插件构建uber jar(构建docker映像),并将项目jar部署到maven存储库。我不想将uber jar部署到maven Repo。因此,要么我需要能够从maven deploy插件中排除特定文件,要么让maven shade插件将uber jar放在不同的位置,这样deploy插件就不会接收到它。 这两件事都有可能吗?

  • 官方文件目录:kubernetes/cluster/addons/fluentd-elasticsearch $ ls *.yaml es-controller.yaml es-rbac.yaml es-service.yaml fluentd-es-ds.yaml kibana-controller.yaml kibana-service.yaml fluentd-es-rbac.yaml