我是 Java 新手(但有相当多的 .NET 经验)。
我需要快速启动并运行一个 Java 应用程序,因此我在这里寻找的是有关组件的建议,这些组件将简化或减少常见任务的痛苦,并且其回报要么是立竿见影的,要么至少是花费最少的时间投资学习如何使用该组件。我没有花几周的时间来掌握复杂或广泛的框架 - 我正在寻找易于使用并消除使用原始 API 的一些问题的插件。但是,如果原始 API 是执行这些任务的最佳选择,那也没关系,请告诉我...
数据层
我想为 MySQL、MSSQL、Postgres 编写特定的提供程序,但除此之外数据访问是非常简单的事情。我可能需要交易。你有什么建议?是否说 Spring Data Access 提供了比 JDBC 更值得拥有的东西?还有什么我需要考虑的吗?我的猜测是 Hibernate 之类的东西会太过分,并且需要很长时间才能启动和运行 - 您认为呢?
中层
松散耦合、基于接口的业务层。我需要能够通过 Web 应用程序和桌面应用程序与中间层进行交互 - 公开这一点的最佳方式是什么?网络服务?
桌面应用
我了解 Swing - 还有其他简单的桌面 UI 组件吗?我将需要某种调度组件来运行后台任务。
网络应用程序
我需要某种缓存,我需要用户会话,我需要动态页面。据我所知,JSP 是 PHP 或其他某种服务器端脚本语言的 Java 等效项(并且不支持状态)。除非有一个非常容易使用的框架,否则 MVC 框架可能有点过大了。我听说有一个与 ASP.NET Web 表单相当的 Java - 它有什么好处吗?也许 JSP 就足够了?
我正在寻找实用的建议/您对组件的体验,而不是网络链接列表:)
感谢您的任何建议..
I am new to Java (but have a fair bit of .NET experience).
I need to get a Java application up and running quickly, so what I am looking for here is advice on components that will simplify or reduce the pain of common tasks and whose payoff will either be immediate or at least come with minimal investment in time spent learning how to use the component. I don't have weeks to spend getting to grips with complex or extensive frameworks - I am looking for add-ins that are easy to use and remove some of the propblems of using raw APIs. However, if the raw API is the best option for any of these tasks, that's fine, let me know ...
Data Layer
I want to write specific providers for MySQL, MSSQL, Postgres but otherwise data access is pretty simple stuff. I will probably need transactions. What do you suggest? Does say, Spring Data Access, offer anything worth having over JDBC? Anything else I need to think about? My guess is something like Hibernate is going to be overkill and take too long to get up and running with - what do you think?
Middle Tier
Loosely coupled, interface based business layer. I need to be able to interact with the middle tier through a web app and a desktop app - what is the best way to expose this? Web service?
Desktop App
I know about Swing - are there any other simple desktop UI components? I will need some kind of scheduling component to run background tasks.
Web App
I will need some kind of cache, I need user sessions, I need dynamic pages. From what I can tell JSPs are a Java equivalent of PHP or some other server side scripting language (and don't support state). An MVC framework may be overkill unless there is a framework that is very straight forward to get working with?. I heard there is a Java equivalent of ASP.NET web forms - is it any good? Maybe JSPs will suffice here?
I'm looking for practical advice / your experiences of components, rather than a list of web links :)
Thanks for any advice ..
发布评论
评论(3)
我会查看 Grails 的模型/控制器/视图机制和 Web 前端。它将让您快速启动并运行 ORM、模型、动态页面等(这是一个 RoR - Ruby-on-Rails - 模型)。
从那里,我将考虑使用 Java RMI与桌面前端通信。 RMI 是 Java 的标准,非常适合 Java 到 Java 的通信需求。除非您有多语言/平台要求,否则我不会考虑网络服务。 RMI 的设置非常简单,只需很少的配置。
支持 RMI 的服务层必须与 Grails 提供的模型进行拦截,但这应该是微不足道的。为了减少可能的客户端/服务器不兼容(由界面更改引起),您可以通过(例如)Java Web Start(您将拥有 Grails 提供的 Web 服务器),它可以来自与您的服务器正在运行的相同代码库。当您更新后端时,会维护最新的部署。
I would check out Grails for the model/controller/view mechanism and web front end. It will get you up and running very quickly with an ORM, a model, dynamic pages etc. (it's a RoR - Ruby-on-Rails - model).
From there, I would look at using Java RMI to communicate with a desktop front end. RMI comes as standard with Java and is a natural fit for a Java-to-Java communication requirement. I wouldn't look at web services unless you have a multi-language/platform requirement. RMI is pretty simple to set up, with little configuration.
Your RMI-enabled service layer will have to intercept with the Grails-provided model, but that should be trivial. To reduce possible client/server incomaptibilities (caused by interface changes), you can serve up the Java desktop via (say) Java Web Start (you'll have a web server courtersy of Grails) and it can come from the same codebase that your server is running. Up-to-date deployments are maintained as you update the back end.
AppFuse 是一个可以启动和预配置各种 java 项目的工具,使用最佳 -做法。生成的代码也可用于通过示例进行学习。
AppFuse 支持以上所有内容。
AppFuse is a tool that can kick-start and preconfigure a variety of java projects, using best-practices. The generated code can also be used to learn-by-example.
AppFuse supports all of the above.
我只会将我的答案限制在网络应用程序部分,因为我想回答其他部分的问题已经被其他人回答了。
不完全正确。 JSP 的功能远不止这些。更重要的是,(ab)以 PHP 方式使用 JSP(使用内联 Java 代码作为 scriptlet)被认为是不好的做法。 JSP 应该用作模板,您可以在其中使用标签库动态控制页面流,例如 JSTL 并使用 表达式语言。
它叫做 JavaServer Faces (JSF)。然而,存在竞争,例如 Apache Struts 和 Spring MVC。
JSF(与任何其他像样的 MVC 框架一样)抽象了您在普通 MVC 应用程序中需要考虑的所有内容,以便您最终只得到一个 XHTML(或 JSP)文件,并且Javabean 类。这样你就不需要控制请求(自定义Servlet等)、处理请求参数(request.getParameter()等)、基本验证/转换(需求、字符串/数字/日期输入类型转换)、更新模型值(在 javabean 中设置已处理/转换/验证的参数)等。MVC 框架将透明地处理所有这些无聊的工作。
如果您只需要为每个 saldo 开发几页,JSP 就足够了。但是,如果您想开发更多页面或网络应用程序,那么您希望已经拥有一个框架,这样您就不需要一次又一次地重新发明通常的工作。
I'll limit my answers to the webapp part only as things I'd like to answer other parts are already answered by others.
Not entirely true. JSP can do more than that. Even more, (ab)using JSPs the PHP way (with inline Java code as scriptlets) is considered bad practice. JSP is supposed to be used as a template in which you can control the page flow dynamically using taglibs such as JSTL and access the backend data using Expression Language.
It's called JavaServer Faces (JSF). There's however competition, e.g. Apache Struts and Spring MVC.
JSF (as any other decent MVC framework) abstracts all the stuff you need to take account with in a normal MVC application away so that you end up with just a XHTML (or JSP) file and a Javabean class. This way you don't need to control requests (custom Servlets, etc), process request parameters (request.getParameter() and so on), the basic validation/conversion (requireness, string/number/date input type conversions), update model values (set processed/converted/validated parameters in javabeans), etc. The MVC framework will take care about all that boring work transparently.
JSPs may suffice if you need to develop per saldo just a few pages. But if you want to develop more pages or webapplications, then you'd like to already have a framework so that you don't need to reinvent the usual work again and again.