简体   繁体   English

简单的Java EE客户端桌面应用程序和带有MySQL的Web

[英]Simple Java EE client desktop application and web with MySQL

At start i have to say that im totaly new to java ee and quite new in java at all. 开始时,我不得不说Java EE完全是全新的,而Java则完全是全新的。 I have to do my study project with this one. 我必须为此做一个研究项目。 First of all i need a standard desktop aplication that connects with the remote mysql database. 首先,我需要一个与远程mysql数据库连接的标准桌面应用程序。 The second one less important is web aplication that connects with database too. 第二个不太重要的是也与数据库连接的Web应用程序。 The question is how the flow of informations should look like according to java ee standards ? 问题是,按照Java EE标准,信息流应如何? Something like client aplication > remote > java beans > local > mysql ? 诸如客户端应用>远程> Java bean>本地> mysql之类的东西? What api's do you recomend with this simple project to take care of ORM etc. ? 您建议使用什么简单的API来处理ORM等简单项目? And the last one i need some tutorials or books about java ee. 最后一个我需要一些有关java ee的教程或书籍。

You actually give too few requirements and constraints, even to choose a technology stack. 实际上,即使选择技术堆栈,您给出的要求和约束也很少。

What i can advise according to your post : 我根据您的帖子可以提供的建议:

Try to factorize the data access layer (DAOs) as you will probably share it between desktop and web application. 尝试分解数据访问层(DAO),因为您可能会在桌面和Web应用程序之间共享它。 For this you have 2 solution : 为此,您有2个解决方案:

Solution 1 : jar module embedded in both application: 解决方案1 :两个应用程序中都嵌入了jar模块
This imply that the component have to be also runnable outside of a server container (Java SE). 这意味着该组件还必须在服务器容器(Java SE)外部也可运行。 I would so advise not to use Java EE but Spring as Java EE does not yet provide a standalone "lightweight" container properly managing persistence context. 我因此建议不要使用Java EE,而是建议使用Spring,因为Java EE尚未提供独立的“轻量级”容器来正确管理持久性上下文。

Spring will allow you to define a data access component with a datasource (plugged to remote DB) and container transaction management (using an ORM outside of a container isn't very interesting imho) which will run alone (desktop app) and inside any servlet container (tomcat, etc) (web app) with for only difference a configuration file. Spring将允许您定义一个具有数据源(插入远程数据库)和容器事务管理(在容器外部使用ORM并不是很有趣的恕我直言)的数据访问组件,该组件将单独运行(桌面应用程序)并在任何servlet中运行容器(tomcat等)(网络应用程序),仅包含一个配置文件。

It will give: 它会给:

Standalone : client [Swing views > controllers > Spring managed DAOs] > remote database 独立服务器 :客户端[Swing视图>控制器> Spring托管DAO]>远程数据库
web : client [html] > web server [any view techno (spring mvc for example) > Spring managed DAOs] > remote or local database Web :客户端[html]> Web服务器[任何视图技术(例如Spring MVC)> Spring托管DAO]>远程或本地数据库

Solution 2 : SOA architecture with a shared data access component instance deployed on the web server and exposed to standalone app through web-services : 解决方案2 :具有共享数据访问组件实例的SOA架构部署在Web服务器上,并通过Web服务公开给独立的应用程序:

standalone : client [swing views > controllers] > http > web or Java EE server [REST or SOAP web-services > DAOs] > local or remote database 独立 :客户端[swing视图>控制器]> http> Web或Java EE服务器[REST或SOAP Web服务> DAO]>本地或远程数据库

web : 网络

  • client [html] > web server [any view techno > DAOs] > local or remote database 客户端[html]> Web服务器[任何视图技术> DAO]>本地或远程数据库
  • client [RIA (Ajax, Flex, etc...)] > web server [REST web services > DAOs] > local or remote database 客户端[RIA(Ajax,Flex等)]> Web服务器[REST Web服务> DAO]>本地或远程数据库

    Otherwise i would advise not to use an ORM if you don't really need it cause the learning curve is quite long compared to advantage it will bring to you. 否则,如果您真的不需要ORM,我建议您不要使用ORM,因为与之相伴的学习曲线相当长。 (Ofc it depends of your context and requirement : complexity of the data model, existing DB or new one, DB exclusively used by your app or shared, existing stored procedure or trigger, high concurrency, etc, etc) (这取决于您的上下文和要求:数据模型的复杂性,现有数据库或新数据库,应用程序专有或共享使用的数据库,现有存储过程或触发器,高并发性等)

  • For the desktop application I would describe the flow as this: Java Application(Core Java) -> EJB (Enterprise Java Beans) -> Hibernate (ORM) -> MySQL (DB) 对于桌面应用程序,我将这样描述流程:Java应用程序(核心Java)-> EJB(企业Java Bean)->休眠(ORM)-> MySQL(DB)

    For the web application: Struts (Front end framework) -> Hibernate -> MySQL 对于Web应用程序:Struts(前端框架)-> Hibernate-> MySQL

    You could also use EJBs in between struts and Hibernate. 您也可以在struts和Hibernate之间使用EJB。 If the projects are related, you actually just need to swap the front end really (The Java App and the Struts component). 如果项目相关,则实际上只需要交换前端(Java App和Struts组件)。

    I wouldn't jump right into piles of frameworks right away. 我不会马上跳入成堆的框架。 I learned much better starting with JSPs and Servlets, then progressing into Struts, then learning Hibernate, etc. Its too much to worry about all at once. 从JSP和Servlet开始,然后进入Struts,然后学习Hibernate等,我学到了很多东西。这太多了,无法一worry而就。

    I don't have books to recommend, but http://www.mkyong.com/ has some decent examples. 我没有值得推荐的书籍,但是http://www.mkyong.com/上有一些不错的例子。

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM