欢迎使用CSDN-markdown编辑器

Posted Lance_xu_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了欢迎使用CSDN-markdown编辑器相关的知识,希望对你有一定的参考价值。

原文链接:http://www.dropwizard.io/1.2.0/docs/getting-started.html

Getting Start

Getting Startedwill guide you through the process of creating a simple Dropwizard Project: Hello World. Along the way, we’ll explain the various underlying libraries and their roles, important concepts in Dropwizard, and suggest some organizational techniques to help you as your project grows. (Or you can just skip to the fun part.)

入门指南将会引导你完成创建一个简单的Dropwizard项目:Hello Word。整个过程中,我们会介绍其引用的底层类库和作用,Zropwizard框架的重要概念,在项目实现过程中介绍一些组织性的技术。(你也可以跳过Getting Start步骤)

Overview

Dropwizard straddles the line between being a library and a framework. Its goal is to provide performant, reliable implementations of everything a production-ready web application needs. Because this functionality is extracted into a reusable library, your application remains lean and focused, reducing both time-to-market and maintenance burdens.

Dropwizard跨越了类库和框架之间的界限。其目的是为Web应用程序提供一种可靠的实现方案。由于此功能被提取到可重用的类库中,因此你的应用程序仍然精简和集中,从而缩短上市时间和维护负担。

Jetty for HTTP

Because you can’t be a web application without HTTP, Dropwizard uses the Jetty HTTP library to embed an incredibly tuned HTTP server directly into your project. Instead of handing your application off to a complicated application server, Dropwizard projects have a main method which spins up an HTTP server. Running your application as a simple process eliminates a number of unsavory aspects of Java in production (no PermGen issues, no application server configuration and maintenance, no arcane deployment tools, no class loader troubles, no hidden application logs, no trying to tune a single garbage collector to work with multiple application workloads) and allows you to use all of the existing Unix process management tools instead.

Web应用程序离不开HTTP,Zropwizard框架直接将Jetty Http插件(Http服务器)嵌入到你的Web应用程序中。你不需要将项目交给一个复杂的Web服务器,Zropwizard项目提供一个main方法快速启动一个HTTP服务器(Jetty)。通过一个简单的过程运行你的Java应用程序而排除一系列复杂的事情。(没有PermGen问题,没有应用服务器配置和维护,没有复杂的部署工具,没有类加载器的困扰,没有隐藏的应用日志,不用调试垃圾回收器来解决多应用负载),允许使用所有现成的Unix进程管理工具。

Jersey for REST

For building RESTful web applications, we’ve found nothing beats Jersey(the JAX-RS reference implementation) in terms of features or performance. It allows you to write clean, testable classes which gracefully map HTTP requests to simple Java objects. It supports streaming output, matrix URI parameters, conditional GET requests, and much, much more.

构建RESTful风格的Web应用程序,我们没有发现任何能够打败Jersey的框架。它允许您编写简洁,可测试的类,将HTTP请求正确地映射到简单的Java对象。它支持流输出,解析URI参数,条件GET请求等等。

Jackson for JSON

In terms of data formats, JSON has become the web’s lingua franca, and Jackson is the king of JSON on the JVM. In addition to being lightning fast, it has a sophisticated object mapper, allowing you to export your domain models directly.

目前的数据格式,JSON已经是一种通用的数据结构,Jackson是JVM解析JSON数据的霸主。除了速度快,Jackson还有一套对象映射器,允许你直接导出你的数据模型。

Metrics for metrics

The Metrics library rounds things out, providing you with unparalleled insight into your code’s behavior in your production environment.

Metrics插件让你代码执行透明化,对你生产环境的代码提供无与伦比的观察能力。

And Friends

In addition to Jetty,Jersey, andJackson, Dropwizard also includes a number of libraries to help you ship more quickly and with fewer regrets.

除了Jetty、Jersey、Jackson之外,Dropwizard还包括许多其他类库帮助你的应用开发,减少烦恼。

Guava, which, in addition to highly optimized immutable data structures, provides a growing number of classes to speed up development in Java.

除了高度优化的不可变数据结构之外,Guava还提供了越来越多的类库来加速Java开发。

Logback and slf4j for performant and flexible logging.

Logback和slf4j用于执行和灵活的日志记录。

Hibernate Validator, the JSR 349 reference implementation, provides an easy, declarative framework for validating user input and generating helpful and i18n-friendly error messages.

Hibernate Validator,JSR 349参考实现,为验证用户输入提供了一个简单的声明框架,并生成有用的和易于使用的I18n友好的错误消息。

The Apache HttpClient and Jersey client libraries allow for both low- and high-level interaction with other web services.

Apache HttpClient和Jersey客户端库允许与其他Web服务进行低级和高级别的交互。

JDBI is the most straightforward way to use a relational database with Java.

JDBI是使用Java的关系数据库最直接的方法。

Liquibase is a great way to keep your database schema in check throughout your development and release cycles, applying high-level database refactorings instead of one-off DDL scripts.

在开发和发布周期中,Liquibase是保持数据库模式的重要方法,应用高级数据库重构而不是一次性DDL脚本。

Freemarker and Mustache are simple templating systems for more user-facing applications.

Freemarker和Mustache是​​简单的系统模板,适用于面向更多用户的应用程序。

Joda Time is a very complete, sane library for handling dates and times.

Joda Time是一个非常完整理智的 ,用于处理日期和时间。

Now that you’ve gotten the lay of the land, let’s dig in!

现在你已经得到了这片土地,让我们开始吧!

Setting Up Using Maven

We recommend you use Maven for new Dropwizard applications. If you’re a big Ant/Ivy,Buildr,Gradle,SBT,Leiningen, or Gant fan, that’s cool, but we use Maven, and we’ll be using Maven as we go through this example application. If you have any questions about how Maven works,Maven: The Complete Reference should have what you’re looking for.

You have three alternatives from here:

Create a project usingdropwizard-archetype

mvn archetype:generate -DarchetypeGroupId=io.dropwizard.archetypes -DarchetypeArtifactId=java-simple -DarchetypeVersion=[REPALCE WITH A VALID DROPWIZARD VERSION]

Look at thedropwizard-example

Follow the tutorial below to see how you can include it in your existing project

以上是关于欢迎使用CSDN-markdown编辑器的主要内容,如果未能解决你的问题,请参考以下文章

欢迎使用CSDN-markdown编辑器

欢迎使用CSDN-markdown编辑器

欢迎使用CSDN-markdown编辑器

欢迎使用CSDN-markdown编辑器

欢迎使用CSDN-markdown编辑器

欢迎使用CSDN-markdown编辑器