dropwizard

Unrecognized Field in Dropwizard YAML File

不打扰是莪最后的温柔 提交于 2020-01-03 17:35:31
问题 I'm getting the following error when launching a Dropwizard application that uses a database connection to MySQL: app.yaml has an error: * Unrecognized field at: database Did you mean?: - metrics - instanceId - logging - server - statsConfig [12 more] At the end of my Dropwizard configuration file, I have the following: database: driverClass: com.mysql.jdbc.Driver user: ${MYSQL_USERNAME} password: ${MYSQL_PASSWORD} url: ${MYSQL_URL} And in my configuration class, I have the following: @Valid(

Unrecognized Field in Dropwizard YAML File

ぃ、小莉子 提交于 2020-01-03 17:35:12
问题 I'm getting the following error when launching a Dropwizard application that uses a database connection to MySQL: app.yaml has an error: * Unrecognized field at: database Did you mean?: - metrics - instanceId - logging - server - statsConfig [12 more] At the end of my Dropwizard configuration file, I have the following: database: driverClass: com.mysql.jdbc.Driver user: ${MYSQL_USERNAME} password: ${MYSQL_PASSWORD} url: ${MYSQL_URL} And in my configuration class, I have the following: @Valid(

Dropwizard : Exception Handling, giving custom error JSON error messages to client

梦想与她 提交于 2020-01-03 10:21:36
问题 How can i configure dropwizard to give custom error messages to User. If my function is supposed to return a object myObject, but since there is an error, it should throw and exception and return a error Object to User with a custom message. 回答1: You can add your own subclass of WebApplicationException like this: public class ObjectNotFoundException extends WebApplicationException { public ObjectNotFoundException() { super(Responses.notFound().build()); } public ObjectNotFoundException(String

How do you inject jdbiFactory DAOs into a Dropwizard Command?

有些话、适合烂在心里 提交于 2020-01-03 07:29:44
问题 I'm starting to work with Dropwizard and I'm trying to create a Command that requires to use the database. If someone is wondering why I'd want to do that, I can provide good reasons, but this is not the point of my question anyway. It's about dependency inversion and Service initialization and run phases in Dropwizard. Dropwizard encourages to use its DbiFactory to build DBI instances but in order to get one, you need an Environment instance and/or the database configuration: public class

Dropwizard and Guice: injecting Environment

狂风中的少年 提交于 2020-01-01 05:04:28
问题 I am currently building a Dropwizard + Guice + Jersey-based application where the database access is being handled by JDBI for the time being. What I am trying to achieve is to have your typical enterprise architecture, where Resources access Service classes accessing a DAO class that in turn accesses the database. It would be nice to get all this wired up in a proper DI way, although I guess I can build my object graph in the run() method of the application if all else fails. So, I'm running

Dropwizard and Guice: injecting Environment

大城市里の小女人 提交于 2020-01-01 05:04:13
问题 I am currently building a Dropwizard + Guice + Jersey-based application where the database access is being handled by JDBI for the time being. What I am trying to achieve is to have your typical enterprise architecture, where Resources access Service classes accessing a DAO class that in turn accesses the database. It would be nice to get all this wired up in a proper DI way, although I guess I can build my object graph in the run() method of the application if all else fails. So, I'm running

Dropwizard: How to stop service programmatically

一曲冷凌霜 提交于 2019-12-30 05:56:08
问题 To start the service, I know one uses new MyService().run(args) . How to stop it? I need to start and stop programmatically for setUp() and tearDown() in my tests. 回答1: You can start the service in new thread, once the test ends the service will shutdown automatically. However starting in dropwizard 0.6.2 the dropwizard-testing module contains a junit rule exactly for this use case (see here). Usage of this rule will look something like this: Class MyTest { @ClassRule public static TestRule

Dropwizard serve external images directory

爱⌒轻易说出口 提交于 2019-12-25 07:35:20
问题 I have a dropwizard API app and I want one endpoint where I can run the call and also upload and image, these images have to be saved in a directory and then served through the same application context. Is it possible with dropwizard? I can only find static assets bundles. 回答1: There is similar question already: Can DropWizard serve assets from outside the jar file? The above module is mentioned in the third party modules list of dropwizard . There is also official modules list. These two

Dropwizard: Unable to serve static HTML

你说的曾经没有我的故事 提交于 2019-12-25 01:44:58
问题 I'm currently working on serving a static html page in Dropwizard at the root path "/". So far, I've only received an error page stating "HTTP ERROR 404 Problem accessing /. Reason: Not Found". I've followed the Dropwizard documentation for 1.2.2 in doing this, as well as this tutorial here, with some changes to the code for my services to work. My root path in my .yml file is /profile/v1 to allow my getAll services to work (when I first started, I was getting an error for having Multiple

Issues with DropWizard Gradle build

不想你离开。 提交于 2019-12-25 01:05:01
问题 I imported a Dropwizard project into Intellij IDEA (using Gradle Wrapper from the project itself). Its working for others, but I end up in issue like this: Here is the gist of gradle dependency. https://gist.github.com/vineelya/d882bbd0885fafba785ca58f106dfc8b Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z dependencies { compile ( 'io.dropwizard:dropwizard-core:' + dropwizardVersion, 'io.dropwizard:dropwizard