eclipse 如何使用 Maven 创建一个 Swing 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2191656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a swing application using maven?
提问by Mustafa Abuelfadl
I was trying to start new swing application using maven, so I started searching on maven documentation but (frustratingly) found no clue. So I'm asking:
我试图使用 maven 启动新的 Swing 应用程序,所以我开始搜索 maven 文档,但(令人沮丧地)找不到任何线索。所以我问:
- what is the archetype used?
- what are the dependencies?
- how to build swing app in maven [is there is plugin to do so]?
- 使用的原型是什么?
- 依赖关系是什么?
- 如何在 Maven 中构建 Swing 应用程序 [是否有插件可以这样做]?
采纳答案by Pascal Thivent
- what is the archetype used?
- 使用的原型是什么?
A swing application is a standard JAR so just use the standard archetype:
Swing 应用程序是标准 JAR,因此只需使用标准原型:
mvn archetype:generate -DgroupId=com.mycompany.app \
-DartifactId=myswingapp \
-Dversion=1.0-SNAPSHOT
- what are the dependencies?
- 依赖关系是什么?
If you plan to use the standard SwingAPI only, there aren't no extra dependencies to declare. But if you want to use things like JGoodies, MiGLayout, SwingX, Flamingo, SwingFXetc then you'll have to add the appropriate artifacts and repositories. But there is no universal answer to your question.
如果您打算仅使用标准SwingAPI,则无需声明额外的依赖项。但是,如果您想使用JGoodies、MiGLayout、SwingX、Flamingo、SwingFX等内容,则必须添加适当的工件和存储库。但是你的问题没有统一的答案。
- how to build swing app in maven [is there is plugin to do so ]?
- 如何在 maven 中构建 Swing 应用程序 [是否有插件可以这样做]?
A Swing app is not really particular. I would maybe just consider using Java Web Start(and the Maven Webstart plugin) or maybe a cross platform installer like IzPack(and the Maven IzPack Plugin). But you have time for that, you need an application before :)
Swing 应用程序并不特别。我可能会考虑使用Java Web Start(和Maven Webstart 插件)或者像IzPack(和Maven IzPack 插件)这样的跨平台安装程序。但是你有时间,你之前需要一个应用程序:)
回答by Romain Linsolas
Basically, if you are only using Swing (I mean if you do not want additional features such as SwingXfor example), then you will not need to add specific information in your pom.xml
file, as everything needed for Swing development is already embedded in the JDK.
基本上,如果您只使用 Swing(我的意思是如果您不想要附加功能,例如SwingX),那么您将不需要在pom.xml
文件中添加特定信息,因为 Swing 开发所需的一切都已经嵌入到 JDK 中.
Concerning the build process, there is also nothing specific additions here. However, you may need be interesed in:
关于构建过程,这里也没有什么具体的补充。但是,您可能需要对以下内容感兴趣:
- Creating an executable JAR.
- Making a big JAR, that also contains all the dependencies.
- 创建一个可执行的 JAR。
- 制作一个大 JAR,其中还包含所有依赖项。
回答by jrbalderrama
Check these links if you have problems finding documentation about maven Better builds with Mavenand Maven: The Definitive Guide. Then you will figure out that you can build any kind of app like swing using maven. Maven is not a framework is project management and comprehension tool.
如果您在查找有关 maven Better builds with Mavenand Maven: The Definitive Guide 的文档时遇到问题,请检查这些链接。然后你会发现你可以使用 maven 构建任何类型的应用程序,比如 Swing。Maven 不是框架,是项目管理和理解工具。
Note:Maven: The Definitive Guide was split into two books. The link goes to the blog post that links to both of them.
注意:Maven:权威指南分为两本书。该链接指向链接到他们两个的博客文章。