dropwizard

Dropwizard configuration by not using .YML file?

夙愿已清 提交于 2019-12-07 21:20:07
问题 I am new to dropwizard. I want to know is their any other way to set the connection port, admin port, logger level and all configuration parameters and not by use .YML file. 回答1: You can use command like param when starting the application. Its all within the docs within the Configuration section. For example: -Ddw.server.applicationConnectors[0].port=9090 来源: https://stackoverflow.com/questions/23730814/dropwizard-configuration-by-not-using-yml-file

What is the correct way to configure custom mapper for WebApplicationException?

让人想犯罪 __ 提交于 2019-12-07 14:47:59
问题 I've created class that implements implements ExceptionMapper<WebApplicationException> and registered it by environment.addProvider(new WebApplicationExceptionMapper()); . My custom mapper works but only for some exceptions extended from WebApplicationException . For example it doesn't work for ConflictException and it also doesn't work for my custom exceptions with following constructor: public ConflictException(URI location, Object entity) { super(Response.status(Response.Status.CONFLICT)

How to create a war from dropwizard app?

萝らか妹 提交于 2019-12-07 11:37:16
问题 I am trying to build a war from dropwizard app and deploy. I could successfully run the jar and access my rest services. Has anybody created and successfully deployed a war from dropwizard app? What is the right approach for it? 回答1: Dropwizard is designed to run as a JAR, not as a WAR file. 回答2: It certainly goes against what Dropwizard is about and isn't exactly recommended, but if you find yourself in an environment where this is forced upon you then this might also be an option: https:/

Jersey - Is there a way to instantiate a Per-Request Resource with parameters?

假如想象 提交于 2019-12-07 10:42:05
问题 Suppose I have this class: @Path("/test") public class TestResource{ private TestService testService; public TestResource(TestService testService){ this.testService = testService; } @GET public String getMessage(){ return testService.getMessage(); } } Then, I want to register it with Jersey. One would do: TestService testService = new TestServiceImpl(); resourceConfig.register(new TestResource(testService)); But the problem is that approach makes a single instance of TestResource. I want to

Dropwizard ExceptionMapper: Validate original header fields

不问归期 提交于 2019-12-07 07:02:27
问题 Does anyone know how I can get the original header fields from request? I would like to validate, if client will receive html or just plain/text response. Can I get this fields inside 'toResponse' method of exceptionMapper? I created exceptionMapper like in this post: http://gary-rowe.com/agilestack/2012/10/23/how-to-implement-a-runtimeexceptionmapper-for-dropwizard/ 回答1: If you did want to get information from the original request object, you can add the following to your controller. import

Bridging from log4j2 to slf4j

左心房为你撑大大i 提交于 2019-12-07 04:35:51
问题 I'm using Slf4j 1.7.x in conjunction with Logback in my applications (it is a Dropwizard-application). Now we have libraries that use the log4j2 (not log4j), and the logging goes to /dev/null . I can't find a logj2-over-slf4j or log4j2-to-slf4j library in any exising maven application, what is the trick? 回答1: You may use the Log4j 2 to SLF4J Adapter to route your Log4j2 logs to your slf4j implementation. You are right that slf4j itself does not provide an adapter for log4j2. 来源: https:/

* Unrecognized field at: database Did you mean?: - metrics - server - logging - DROPWIZARD

☆樱花仙子☆ 提交于 2019-12-07 03:13:21
问题 I cannot start my dropwizard application after add database details in my application configuration file (server.yml). server.yml (app config file) server: applicationConnectors: - type: http port: 8080 adminConnectors: - type: http port: 9001 database: # the name of your JDBC driver driverClass: org.postgresql.Driver # the username user: dbuser # the password password: pw123 # the JDBC URL url: jdbc:postgresql://localhost/database # any properties specific to your JDBC driver: properties:

How to deploy an angularjs application frontend with Nginx and dropwizard

送分小仙女□ 提交于 2019-12-06 18:35:05
问题 I'm developing an application using angularjs application frontend having as backend dropwizard. I'm planning to use Nginx as gateway for the backend dropwizard server and as an asset server (images and maybe the angularjs application). My question is what is the best strategy for deployement: Bundling angularjs with the dropwizard backend and using nginx as frontend? Deploying angularjs application on the nginx server? Thanks in advance, 回答1: Following this answer You can use this nginx

Bean validation in DropWizard with custom Json output

为君一笑 提交于 2019-12-06 14:56:06
问题 I have developing a webservice with a variety of Rest functions. I would like to use the standard @Valid annotation to validate my beans. I do however want to modify the the output json error. Error messages from the validation is currently formatted like this: { "errors": [ "someString size must be between 0 and 140", "anotherString cannot contain numbers" ] } I do however want the error messages to be formatted like this: { "errors": [{ "someString": "size must be between 0 and 140" }, {

Using Dropwizard & JDBI to query database with multiple schemas?

人盡茶涼 提交于 2019-12-06 14:48:40
问题 I'm building a Java Rest API with DropWizard (which uses JDBI) and my requirements are that I need to query multiple MySQL schemas with the same application. It'll basically be one AWS MySQL instance housing multiple schemas -- one schema per client. What I need is a mechanism which knows which "schema" to query depending on the request -- IE: which client a request belongs to. I know how to create a DataSource, DAO, etc (using this tutorial: https://dropwizard.github.io/dropwizard/manual