【问题标题】:Wildfly Swarm start browser on mvn runWildfly Swarm 在 mvn run 上启动浏览器
【发布时间】:2016-10-13 04:31:10
【问题描述】:

在运行 mvn wildfly-swarm:run 时,是否有可能打开带有 localhost:8080/index.html 选项卡的浏览器?

非常感谢您的回答!

【问题讨论】:

    标签: maven microservices wildfly-swarm


    【解决方案1】:

    您可以结合使用 groovy 和 java.awt.Desktop 类(大约从 Java 1.6 开始)来打开您希望的任何 URL:

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scripts>
                        <script>
                        <![CDATA[
                            import java.awt.Desktop
                            import java.net.URI
                            Desktop.getDesktop().browse(new URI("http://www.example.com"))
                        ]]>
                        </script>
                    </scripts>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <!-- any version of Groovy \>= 1.5.0 should work here -->
                        <version>2.4.7</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    

    (这个是在OSX上测试的,但是由于使用的是java Desktop类,应该是跨平台的)

    【讨论】:

    • 不幸的是,当我启动应用程序时它没有。
    • 什么意思?
    • 好的,所以我通过将执行阶段从安装更改为打包来运行它。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2017-06-01
    • 2016-09-13
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多