Soon I will have to start a web project for a company, and I now need to choose a technology to build the app. I'm thinking about using Java, hence I'd like to find a framework that will help me building the app (I'm used to PHP framework such as CakePHP & CodeIgniter).
很快,我将不得不为一家公司启动一个Web项目,现在我需要选择一种技术来构建应用程序。我正在考虑使用Java,因此我想找到一个框架来帮助我构建应用程序(我已经习惯了PHP框架,如CakePHP和CodeIgniter)。
What I don't understand is that it seems to exist a lot of framework and technologies that don't have the same goal. Action framework, Component framework ... what can I do with one I can't do with another ? It seems a java web app should be developped by mixing a lots of different technologies, hence I'm a bit lost ... I've had a look at differents java frameworks, such as JSF, Stripes, Struts2, Tapestry, Wicket and Spring. About the later, I don't quiet see what are the different parts of this framework, what can it do for me and what it can't. What can I take from Spring and what I don't need...
我不明白的是,似乎存在许多没有相同目标的框架和技术。行动框架,组件框架......我可以用另一个我不能做的事情做什么?似乎应该通过混合许多不同的技术来开发java Web应用程序,因此我有点迷失...我已经看过不同的java框架,例如JSF,Stripes,Struts2,Tapestry,Wicket和弹簧。关于后者,我不清楚这个框架的不同部分是什么,它能为我做什么以及它不能做什么。我可以从Spring获得什么以及我不需要什么......
Hence : what do I need to build a java web application ?
因此:构建java Web应用程序需要什么?
I've already used JSF for a basic CRUD app, but I'm trying to find something that may better suits my need. The app we'll have to build will be both a community platform as well as a merchant site, with sensible datas to protect :)
我已经将JSF用于基本的CRUD应用程序,但我正在尝试找到更适合我需要的东西。我们必须构建的应用程序既可以是社区平台,也可以是商家网站,并提供合理的数据保护:)
About the ORM, I guess I'll just go with Hibernate ... Also I've heard about Maven or Ant, in what way can they help me ?
关于ORM,我想我会选择Hibernate ...我也听说过Maven或Ant,他们会以什么方式帮助我?
Any advice/guideline would be much appreciated :-) Thanks in advance.
任何建议/指南将不胜感激:-)在此先感谢。
Edit : what my needs are : a java framework that is :
编辑:我的需求是:一个java框架:
- well documented / easy to get help / as easy as possible ...
- the more java, the better
- Ajax friendly / Facility to build nice UI ...
- Internationalization
- Still being a student, Marketability of Skills might matters ...
记录良好/易于获得帮助/尽可能简单...
java越多越好
Ajax友好/设施构建漂亮的UI ...
仍然是学生,技能的可销售性可能很重要......
The app to be build is both a
要构建的应用程序都是一个
- Community site : web 2.0, CRUD
- E-commerce site
社区网站:web 2.0,CRUD
full specs aren't finished yet.
完整的规格尚未完成。
5 个解决方案
#1
This is a very tough question to answer, having been in your situation recently I will try to give some insight. Basically, with Java there is a ton of choice for frameworks and no one can really tell you which one is best-fit for you, what we can do is give you a breakdown of some of the technologies.
这是一个非常难以回答的问题,最近我一直在你的情况下尝试给出一些见解。基本上,使用Java,框架有很多选择,没有人能真正告诉你哪一个最适合你,我们能做的就是给你一些技术细分。
The following is what I have come across in search of the same answers you want.
以下是我在寻找您想要的相同答案时遇到的情况。
Java has a bunch of technologies that try to provide a full-stack solution. These technologies can be broken up into other technologies but work well when you use them together.
Java有许多技术试图提供全栈解决方案。这些技术可以分解为其他技术,但在一起使用时效果很好。
Basically, there are 3 tiers to web applications, the presentation, business and data tier. The presentation tier is the front end, what the user sees. You can generally mix and match technologies for these three layers. You could for example use a stripes front-end with the Spring framework for IOC and Hibernate as your ORM.
基本上,Web应用程序,表示,业务和数据层有3层。表示层是前端,用户看到的内容。您通常可以混合和匹配这三个层的技术。例如,您可以使用带有IOC和Hibernate的Spring框架的条带前端作为您的ORM。
There are many great technologies that you can use for the presentation layer, including Spring-MVC, STRUTS, Stripes, Wicket, JSF/SEAM and Tapestry among a few. Most of these use a JSP for the view using JSTL, with the exception of wicket which actually full separates the html from the logic by using Java "components" (POJOS). There are benefits and drawbacks to both approaches. The benefit of the wicket approach is that you have static typechecking and a complete separation of the html so you can hand it off to your designer.
您可以将许多出色的技术用于表示层,包括Spring-MVC,STRUTS,Stripes,Wicket,JSF / SEAM和Tapestry等。其中大多数使用JSTL为视图使用JSP,但wicket除外,它实际上通过使用Java“组件”(POJOS)将html与逻辑完全分开。两种方法都有利有弊。 wicket方法的好处是你有静态类型检查和html的完全分离,所以你可以把它交给你的设计师。
For the business layer generally people use some sort of Inversion of Control framework (IOC) for Dependency Injection (DI). The popular frameworks for IOC are Spring and Seam, these have associated technologies like Spring-security and generally are supported by the other technologies. Google Guice seems to be popular for a straight DI framework.
对于业务层,人们通常使用某种控制反转框架(IOC)进行依赖注入(DI)。 IOC的流行框架是Spring和Seam,它们具有Spring-security等相关技术,并且通常由其他技术支持。 Google Guice似乎很受直接DI框架的欢迎。
Finally, for the data layer most people tend to use Hibernate or JPA. There are others, but I have no experience with them and cannot offer any more information.
最后,对于数据层,大多数人倾向于使用Hibernate或JPA。还有其他人,但我没有经验,也无法提供更多信息。
Tapestry is another framework that attempts to be a full stack from what I understand and takes a wicket like (or I guess Wicket takes a tapestry-like) approach. Grails is yet another full-stack framework using Groovy and built on top of Spring and Hibernate. If you like Rails, Grails is pretty good.
Tapestry是另一个框架,它试图从我的理解中获得完整的堆栈,并采用类似wicket(或者我猜Wicket采用类似挂毯)的方法。 Grails是另一个使用Groovy并构建在Spring和Hibernate之上的全栈框架。如果你喜欢Rails,Grails非常好。
Most of these technologies have a lot of information available and very active mailing lists / IRC chatrooms. What you need to do is take a look at them and then decide which approach is the right one for you. No one here is able to tell you what you will like.
大多数这些技术都有很多可用的信息和非常活跃的邮件列表/ IRC聊天室。你需要做的是看看它们,然后决定哪种方法适合你。这里没有人能够告诉你你想要什么。
If you want a recommendation, I would like to one day use a Wicket/Guice/Hibernate stack.
如果你想要一个推荐,我想有一天使用Wicket / Guice / Hibernate堆栈。
#2
My favourite is definitely Spring. The new Spring MVC 2.5 is easy and quick to set up, lots of annotations to help you wire your controllers declaratively which saves you a lot of typing. It also integrates with the Spring container which is definitely my favourite light-weight J2EE replacement container. I usually combine SpringMVC with simple JSP, but there are a lot of other view techs to choose from. For persistence I usually use Hibernate. Might be worthwhile to take a look at Spring ROO which is kind of like Grails without Groovy. Spring Security offers a nice and easy declarative way of doing security and integrates into a whole bunch of authentication technologies.
我最喜欢的是春天。新的Spring MVC 2.5设置简单快捷,大量注释可帮助您以声明方式连接控制器,从而为您节省大量的打字工作。它还与Spring容器集成,这绝对是我最喜欢的轻量级J2EE替换容器。我通常将SpringMVC与简单的JSP结合起来,但是还有很多其他的视图技术可供选择。对于持久性我通常使用Hibernate。可能值得一看Spring ROO,有点像没有Groovy的Grails。 Spring Security提供了一种简单易用的声明式安全方法,并集成到一大堆身份验证技术中。
Maven and ant are both build tools while maven also handles dependencies for you. You "just" set up descriptors that describe the libraries you want and the version requirements, and maven will download all libraries and their dependencies for you. It forces you to follow a certain project layout, though. For ant there's ivy which does dependencies.
Maven和ant都是构建工具,而maven也为你处理依赖。您只需设置描述所需库和版本要求的描述符,maven就会为您下载所有库及其依赖项。但是,它会强制您遵循某个项目布局。对于蚂蚁来说,常春藤有依赖性。
#3
I suggest you have a look at Grails. Grails is a "coding by convention" web application framework build upon a stack of proven Java frameworks (Spring, Hibernate, ...) and using the Groovy language..
我建议你看看Grails。 Grails是一个“按惯例编码”Web应用程序框架,构建在一堆经过验证的Java框架(Spring,Hibernate,...)和使用Groovy语言之上。
The beauty of Grails is that you need little knowledge of Spring, Hibernate, etc. to get started. But afterwards you still have access to the full power of these frameworks should it be necessary.
Grails的美妙之处在于,您无需了解Spring,Hibernate等即可开始使用。但是,如果有必要,您仍然可以获得这些框架的全部功能。
#4
Definitely use Spring for the back end; there's an excellent community on their free support forum (you can also pay for more formal support).
绝对使用Spring作为后端;在他们的免费支持论坛上有一个很好的社区(你也可以支付更多的正式支持)。
Regarding your decision to use Hibernate, you might want to code against JPA in order to decouple your app from Hibernate (which is one of several JPA implementations).
关于您决定使用Hibernate,您可能希望针对JPA进行编码,以便将您的应用与Hibernate(这是几个JPA实现之一)分离。
If you want an Ajax front-end, it's worth taking a look at the ZK framework; it'svery easy to use without having to learn JavaScript, and avoids having to use plumbing libraries like DWR.
如果你想要一个Ajax前端,那么值得一看ZK框架;它非常容易使用而无需学习JavaScript,并且避免使用像DWR这样的管道库。
#5
The advice of others to use Spring is an excellent idea. You will find that you will actually use a number of different frameworks together because each framework solves a slightly different problem.
其他人使用Spring的建议是一个很好的主意。你会发现你实际上会使用许多不同的框架,因为每个框架解决了一个稍微不同的问题。
I would suggest that you invest some time with each framework or technology before jumping in but you will eventually want to get them to work together. You may want a Struts + Spring + Hibernate setup for instance. Configuring them could be a headache.
我建议你在进入之前投入一些时间与每个框架或技术,但你最终会希望让他们一起工作。例如,您可能需要Struts + Spring + Hibernate设置。配置它们可能很头疼。
So I suggest that you use AppFuse which helps by generating the basic application with basic functionality. Its a huge time saver. You will of course need to understand the different frameworks that are configured for you so its not a magic solution.
因此,我建议您使用AppFuse,它可以通过生成具有基本功能的基本应用程序来提供帮助。它节省了大量时间。您当然需要了解为您配置的不同框架,因此它不是一个神奇的解决方案。
#1
This is a very tough question to answer, having been in your situation recently I will try to give some insight. Basically, with Java there is a ton of choice for frameworks and no one can really tell you which one is best-fit for you, what we can do is give you a breakdown of some of the technologies.
这是一个非常难以回答的问题,最近我一直在你的情况下尝试给出一些见解。基本上,使用Java,框架有很多选择,没有人能真正告诉你哪一个最适合你,我们能做的就是给你一些技术细分。
The following is what I have come across in search of the same answers you want.
以下是我在寻找您想要的相同答案时遇到的情况。
Java has a bunch of technologies that try to provide a full-stack solution. These technologies can be broken up into other technologies but work well when you use them together.
Java有许多技术试图提供全栈解决方案。这些技术可以分解为其他技术,但在一起使用时效果很好。
Basically, there are 3 tiers to web applications, the presentation, business and data tier. The presentation tier is the front end, what the user sees. You can generally mix and match technologies for these three layers. You could for example use a stripes front-end with the Spring framework for IOC and Hibernate as your ORM.
基本上,Web应用程序,表示,业务和数据层有3层。表示层是前端,用户看到的内容。您通常可以混合和匹配这三个层的技术。例如,您可以使用带有IOC和Hibernate的Spring框架的条带前端作为您的ORM。
There are many great technologies that you can use for the presentation layer, including Spring-MVC, STRUTS, Stripes, Wicket, JSF/SEAM and Tapestry among a few. Most of these use a JSP for the view using JSTL, with the exception of wicket which actually full separates the html from the logic by using Java "components" (POJOS). There are benefits and drawbacks to both approaches. The benefit of the wicket approach is that you have static typechecking and a complete separation of the html so you can hand it off to your designer.
您可以将许多出色的技术用于表示层,包括Spring-MVC,STRUTS,Stripes,Wicket,JSF / SEAM和Tapestry等。其中大多数使用JSTL为视图使用JSP,但wicket除外,它实际上通过使用Java“组件”(POJOS)将html与逻辑完全分开。两种方法都有利有弊。 wicket方法的好处是你有静态类型检查和html的完全分离,所以你可以把它交给你的设计师。
For the business layer generally people use some sort of Inversion of Control framework (IOC) for Dependency Injection (DI). The popular frameworks for IOC are Spring and Seam, these have associated technologies like Spring-security and generally are supported by the other technologies. Google Guice seems to be popular for a straight DI framework.
对于业务层,人们通常使用某种控制反转框架(IOC)进行依赖注入(DI)。 IOC的流行框架是Spring和Seam,它们具有Spring-security等相关技术,并且通常由其他技术支持。 Google Guice似乎很受直接DI框架的欢迎。
Finally, for the data layer most people tend to use Hibernate or JPA. There are others, but I have no experience with them and cannot offer any more information.
最后,对于数据层,大多数人倾向于使用Hibernate或JPA。还有其他人,但我没有经验,也无法提供更多信息。
Tapestry is another framework that attempts to be a full stack from what I understand and takes a wicket like (or I guess Wicket takes a tapestry-like) approach. Grails is yet another full-stack framework using Groovy and built on top of Spring and Hibernate. If you like Rails, Grails is pretty good.
Tapestry是另一个框架,它试图从我的理解中获得完整的堆栈,并采用类似wicket(或者我猜Wicket采用类似挂毯)的方法。 Grails是另一个使用Groovy并构建在Spring和Hibernate之上的全栈框架。如果你喜欢Rails,Grails非常好。
Most of these technologies have a lot of information available and very active mailing lists / IRC chatrooms. What you need to do is take a look at them and then decide which approach is the right one for you. No one here is able to tell you what you will like.
大多数这些技术都有很多可用的信息和非常活跃的邮件列表/ IRC聊天室。你需要做的是看看它们,然后决定哪种方法适合你。这里没有人能够告诉你你想要什么。
If you want a recommendation, I would like to one day use a Wicket/Guice/Hibernate stack.
如果你想要一个推荐,我想有一天使用Wicket / Guice / Hibernate堆栈。
#2
My favourite is definitely Spring. The new Spring MVC 2.5 is easy and quick to set up, lots of annotations to help you wire your controllers declaratively which saves you a lot of typing. It also integrates with the Spring container which is definitely my favourite light-weight J2EE replacement container. I usually combine SpringMVC with simple JSP, but there are a lot of other view techs to choose from. For persistence I usually use Hibernate. Might be worthwhile to take a look at Spring ROO which is kind of like Grails without Groovy. Spring Security offers a nice and easy declarative way of doing security and integrates into a whole bunch of authentication technologies.
我最喜欢的是春天。新的Spring MVC 2.5设置简单快捷,大量注释可帮助您以声明方式连接控制器,从而为您节省大量的打字工作。它还与Spring容器集成,这绝对是我最喜欢的轻量级J2EE替换容器。我通常将SpringMVC与简单的JSP结合起来,但是还有很多其他的视图技术可供选择。对于持久性我通常使用Hibernate。可能值得一看Spring ROO,有点像没有Groovy的Grails。 Spring Security提供了一种简单易用的声明式安全方法,并集成到一大堆身份验证技术中。
Maven and ant are both build tools while maven also handles dependencies for you. You "just" set up descriptors that describe the libraries you want and the version requirements, and maven will download all libraries and their dependencies for you. It forces you to follow a certain project layout, though. For ant there's ivy which does dependencies.
Maven和ant都是构建工具,而maven也为你处理依赖。您只需设置描述所需库和版本要求的描述符,maven就会为您下载所有库及其依赖项。但是,它会强制您遵循某个项目布局。对于蚂蚁来说,常春藤有依赖性。
#3
I suggest you have a look at Grails. Grails is a "coding by convention" web application framework build upon a stack of proven Java frameworks (Spring, Hibernate, ...) and using the Groovy language..
我建议你看看Grails。 Grails是一个“按惯例编码”Web应用程序框架,构建在一堆经过验证的Java框架(Spring,Hibernate,...)和使用Groovy语言之上。
The beauty of Grails is that you need little knowledge of Spring, Hibernate, etc. to get started. But afterwards you still have access to the full power of these frameworks should it be necessary.
Grails的美妙之处在于,您无需了解Spring,Hibernate等即可开始使用。但是,如果有必要,您仍然可以获得这些框架的全部功能。
#4
Definitely use Spring for the back end; there's an excellent community on their free support forum (you can also pay for more formal support).
绝对使用Spring作为后端;在他们的免费支持论坛上有一个很好的社区(你也可以支付更多的正式支持)。
Regarding your decision to use Hibernate, you might want to code against JPA in order to decouple your app from Hibernate (which is one of several JPA implementations).
关于您决定使用Hibernate,您可能希望针对JPA进行编码,以便将您的应用与Hibernate(这是几个JPA实现之一)分离。
If you want an Ajax front-end, it's worth taking a look at the ZK framework; it'svery easy to use without having to learn JavaScript, and avoids having to use plumbing libraries like DWR.
如果你想要一个Ajax前端,那么值得一看ZK框架;它非常容易使用而无需学习JavaScript,并且避免使用像DWR这样的管道库。
#5
The advice of others to use Spring is an excellent idea. You will find that you will actually use a number of different frameworks together because each framework solves a slightly different problem.
其他人使用Spring的建议是一个很好的主意。你会发现你实际上会使用许多不同的框架,因为每个框架解决了一个稍微不同的问题。
I would suggest that you invest some time with each framework or technology before jumping in but you will eventually want to get them to work together. You may want a Struts + Spring + Hibernate setup for instance. Configuring them could be a headache.
我建议你在进入之前投入一些时间与每个框架或技术,但你最终会希望让他们一起工作。例如,您可能需要Struts + Spring + Hibernate设置。配置它们可能很头疼。
So I suggest that you use AppFuse which helps by generating the basic application with basic functionality. Its a huge time saver. You will of course need to understand the different frameworks that are configured for you so its not a magic solution.
因此,我建议您使用AppFuse,它可以通过生成具有基本功能的基本应用程序来提供帮助。它节省了大量时间。您当然需要了解为您配置的不同框架,因此它不是一个神奇的解决方案。