我一直在尝试将文件上传到dropwizard 0.8.1但无法这样做。每次我点击上传呼叫资源方法都不会被调用。 好像我的版本不匹配问题。以下是我的配置/版本文件。
buildscript {
repositories {
mavenCentral()
}
dependencies {
// this plugin
classpath 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:0.4.14'
// add additional dependencies here if you wish to reference instead of generate them (see example directory)
}
}
plugins {
id 'eclipse'
id 'application'
id 'com.github.johnrengelman.shadow' version '1.2.1'
id "org.flywaydb.flyway" version "3.2.1"
}
if (System.getProperty("jsonschema2pojo")) {
apply plugin: 'jsonschema2pojo'
}
apply plugin: 'java'
version = '0.1'
configurations {
all*.exclude group: 'com.sun.jersey', module: 'jersey-core'
all*.exclude group: 'org.slf4j', module: 'slf4j-simple'
}
project.ext {
dropwizardVersion = '0.8.1'
dropwizardSwaggerVersion = '0.7.0'
dropwizardConfig = './src/main/resources/qlue-config.yml'
dropwizardMetrics = '3.1.0'
postgresVersion = '9.4-1201-jdbc41'
apacheCommonsBeanUtilsVersion = '1.9.2'
lombokVersion = '1.16.6'
junitVersion = '4.12'
oauthVersion = '1.0.0'
postgresEmbedded = '1.5-SNAPSHOT'
freemakerVersion = '2.3.23'
websocketBundle = '1.0.0'
reactorVersion = '2.0.6.RELEASE'
}
repositories {
mavenCentral()
maven {
url 'http://oss.sonatype.org/content/repositories/snapshots'
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'io.dropwizard:dropwizard-core:' + dropwizardVersion
compile 'io.dropwizard:dropwizard-jdbi:' + dropwizardVersion
compile 'io.dropwizard:dropwizard-client:' + dropwizardVersion
compile 'io.dropwizard:dropwizard-jackson:' + dropwizardVersion
compile 'io.dropwizard:dropwizard-auth:' + dropwizardVersion
compile 'io.dropwizard.metrics:metrics-core:' + dropwizardMetrics
compile 'io.federecio:dropwizard-swagger:' + dropwizardSwaggerVersion
compile 'commons-beanutils:commons-beanutils:' + apacheCommonsBeanUtilsVersion
compile 'org.postgresql:postgresql:' + postgresVersion
compile 'org.projectlombok:lombok:' + lombokVersion
compile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:' + oauthVersion
compile 'org.freemarker:freemarker:' + freemakerVersion
compile 'org.antlr:antlr:3.2'
compile 'be.tomcools:dropwizard-websocket-jee7-bundle:' + websocketBundle
compile 'edu.stanford.nlp:stanford-corenlp:3.5.2'
compile group: 'edu.stanford.nlp', name: 'stanford-corenlp', version: '3.5.2', classifier: 'models'
compile 'io.swagger:swagger-parser:1.0.13'
compile 'io.swagger:swagger-codegen:2.1.4'
compile 'com.github.kagkarlsson:db-scheduler:1.4'
compile 'org.rythmengine:rythm-engine:1.1.4-SNAPSHOT'
compile 'org.glassfish.jersey.media:jersey-media-multipart:2.17'
testCompile 'junit:junit:' + junitVersion
testCompile 'io.dropwizard:dropwizard-testing:' + dropwizardVersion
testCompile 'org.flywaydb:flyway-core:3.2.1'
testCompile 'ru.yandex.qatools.embed:postgresql-embedded:' + postgresEmbedded
// Required if generating equals, hashCode, or toString methods
compile 'commons-lang:commons-lang:2.6'
// Required if generating JSR-303 annotations
compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.1.4'
// Required if generating JodaTime data types
compile 'joda-time:joda-time:2.2'
//for json path
compile 'com.jayway.jsonpath:json-path:2.0.0'
compile 'com.h2database:h2:1.3.170'
compile 'org.codehaus.groovy:groovy-all:2.4.5'
}
mainClassName = "com.qlue.QlueApp"
shadowJar {
mergeServiceFiles()
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
jar {
manifest { attributes 'Main-Class': mainClassName }
}
test {
reports {
junitXml.enabled = false
html.enabled = true
}
}
// running into bug https://github.com/flyway/flyway/issues/1001
flyway {
url = 'jdbc:postgresql://demo3.folio3.com/qluedev'
user = 'qlue'
password = 'qlue'
}
if (System.getProperty("jsonschema2pojo")) {
jsonSchema2Pojo {
source = file("${project.projectDir}/src/main/resources/assets").listFiles().findAll{it.name.endsWith(".json")}
targetDirectory = file("${project.projectDir}/src/main/java")
targetPackage = 'com.qlue.module.designtime.gen'
includeJsr303Annotations = true
propertyWordDelimiters = ['_'] as char[]
sourceType = 'jsonschema'
annotationStyle = 'jackson2'
}
}
run { args 'server', dropwizardConfig }
我的上传代码就是这个
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation(value = "Uploads the media(image) into the database and returns back id")
@ApiResponses({ @ApiResponse(code = 422, message = "Validation error.") })
public MediaDto receive(@FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader ) {
return mediaService.receiveMultipart(inputStream, contentDispositionHeader);
}
我在这里缺少什么。