【问题标题】:Wildfly Maven Plugin - commands seem to have no effectWildfly Maven 插件 - 命令似乎没有效果
【发布时间】:2020-06-09 13:21:15
【问题描述】:

我正在使用 Wildfly Maven 插件,它正在工作,因为它可以打开,运行 Web 应用程序,但是我的自定义配置有问题,即:

  • 将根记录器和控制台记录器设置为调试模式
  • 允许来自 0.0.0.0:8080 或 localhost 以外的连接。

这是我的设置:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>2.0.2.Final</version>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <java-opts>
            <java-opt>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044</java-opt>
        </java-opts>
        <commands>
            <!-- **These are the commands that aren't going through** -->
            <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
            <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
            <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
            <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
            <command>/subsystem-----Enable Remote access here?</command>
        </commands>
        <add-user>
            <users>
                <user>
                    <username>admin</username>
                    <password>admin.1234</password>
                </user>
                <user>
                    <username>admin-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>admin</group>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
                <user>
                    <username>default-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
            </users>
        </add-user>
    </configuration>
</plugin>

我知道从终端开始时,会使用这个:./standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 但是我直接从 Maven 运行演示,需要从另一台机器访问我的 webapp。

注意 - 在 Wildfly 管理页面中,我可以手动将 Root Logger 和 Console Logger 设置为调试模式,然后正确的调试日志将流出。

例如,我可以手动转到这里:http://127.0.0.1:9990/console/index.html#logging-configuration,然后手动将日志记录从默认的 INFO 级别更改为 DEBUG:

所以我的问题是,除了允许远程访问之外,如何将日志记录级别作为命令更改为 maven wildfly 插件。

【问题讨论】:

    标签: java maven wildfly wildfly-maven-plugin


    【解决方案1】:

    您需要将插件版本升级到 2.1.0.Beta1 才能使其正常工作。 2.0.x 版本无法从 run 或 deploy 目标执行 CLI 命令。

    如果您需要坚持使用您正在使用的版本,则需要定义 execute-commands 目标。然后你可以使用嵌入式服务器来配置服务器。

    <commands>
        <!-- **These are the commands that aren't going through** -->
        <command>embed-server</command>
        <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
        <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
        <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
        <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
        <command>/subsystem-----Enable Remote access here?</command>
        <command>stop-embedded-server</command>
    </commands>
    

    【讨论】:

    • 谢谢!我没有意识到这是一个“新”功能。
    • 至于远程访问 - 你知道我应该使用什么命令来允许从 0.0.0.0 进行远程访问吗?
    • Nvm,发现是&lt;java-opt&gt;-Djboss.bind.address=0.0.0.0&lt;/java-opt&gt;
    • 你也可以使用&lt;serverArgs&gt;&lt;serverArg&gt;-b=0.0.0.0&lt;/serverArg&gt;&lt;/serverArgs&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 2018-05-18
    • 1970-01-01
    • 2010-12-24
    • 2020-07-04
    • 2014-11-06
    相关资源
    最近更新 更多