首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NetBeans和类似Eclipse的“运行配置”

NetBeans和类似Eclipse的“运行配置”
EN

Stack Overflow用户
提问于 2009-08-12 19:26:35
回答 3查看 9.2K关注 0票数 10

可以在NetBeans中创建类似于Eclipse的“运行配置”的东西吗?我正在做一个巨大的项目,该项目目前在Eclipse中没有划分为任何子项目。事实上,项目中有许多应用程序都有自己的main-method和单独的类路径。我知道,一团糟。

我正在考虑将这个项目迁移到NetBeans。从长远来看,创建许多项目是明智的,但现在,如果我可以在NetBeans中做与在Eclipse中类似的事情,那么它将是一个真正的救命稻草:创建具有自己类路径的“启动器”。这个是可能的吗?

如果很容易用“外部”项目来模仿这种行为,那么也欢迎关于这方面的提示。

EN

回答 3

Stack Overflow用户

发布于 2010-03-22 03:35:18

几个月后,我不知道这是否有什么意义:http://wiki.netbeans.org/FaqTwoMainClassesWithArguments

票数 4
EN

Stack Overflow用户

发布于 2017-02-04 01:25:24

在Maven中使用Profiles与Eclipse提供的Run Configuirations很接近,但不是很灵活。这样你就可以在POM.xml中定义你的配置文件了

代码语言:javascript
复制
<profiles>
    <profile>
        <id>Config1</id>
        <build>
            <plugins>
                <plugin>
                    <!-- create an all-in-one executable jar with maven-shade-plugin bound 
                        to phase:package special handling for spring.handlers/spring.schemas files 
                        to prevent overwriting (maven-shade-plugin joins them to one file) usage: 
                        cd to <project>/target java -jar hello-world-java-1.0-executable.jar spring/batch/job/hello-world-job.xml 
                        helloWorldJob -->
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.7</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <!-- Added this one because of runtime exception - No container 
                                        provider supports the type class org.glassfish.grizzly.http.server.HttpHandler 
                                        see - http://stackoverflow.com/questions/9787265/grizzly-and-jersey-standalone-jar -->
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>com.myCompany.nexgen.main.Start</mainClass>
                                        <!-- <mainClass>org.springframework.boot.loader.Launcher</mainClass> -->
                                    </transformer>
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                </transformers>
                                <shadedArtifactAttached>true</shadedArtifactAttached>
                                <!-- configures the suffix name for the executable jar here it will 
                                    be '<project.artifact>-<project.version>-executable.jar' -->
                                <shadedClassifierName>executable</shadedClassifierName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>myLocalrun</id>
        <build>
            <directory>
                c:\sdev\myDev\myProj
            </directory>
        </build>
    </profile>
</profiles>

然后在Project Properties中单击Run。您的配置文件将列在Configuration:的下拉菜单中。在这里,您可以为POM中列出的每个配置文件创建参数。

这并不是这个问题的完整答案。显然,NetBeans缺乏在集成开发环境中快速、轻松地在运行配置之间切换的能力,并且这些配置独立于构建工具并且位于存储库之外。我连接到不同的数据库,并根据我正在处理的项目的不同方面使用不同的输入配置。这在NetBeans中是非常有限的。我不希望我所有的运行配置都签入到存储库中,这就是将配置文件添加到项目POM中时会发生的事情。

编辑:所以我就快找到上面的答案了。单击Customize...按钮,您现在可以选择

对此

实例保持私有

现在,此配置文件/配置将不会存储在POM中。实际上,它存储在Project Files - nb-configuration.xml中。

票数 3
EN

Stack Overflow用户

发布于 2009-08-13 10:32:20

我要做的就是使用Ant,并让一堆目标调用您所在的main()方法。

事实上,这样做的好处是,您甚至可以在IDE外部的命令行上使用这些“快捷键”,这对于持续集成构建和诸如此类的事情很有用。

请注意,NetBeans甚至允许您为您选择的Ant目标定义工具栏/菜单快捷方式,我发现这非常有用。

例如,我的项目构建文件通常都有启动和停止Tomcat的快捷方式,请参见下面的示例:

http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1268211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档