我试图创建战争文件并添加谷歌应用引擎工件
gradlew clean build
曾经在谷歌和 gretty artifacts 之前工作得很好
但添加后
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
classpath 'org.akhikhl.gretty:gretty:+'
}
}
plugins {
....showing only new ones
id 'war'
id 'org.akhikhl.gretty' version '2.0.0'
}
apply plugin: 'com.google.cloud.tools.appengine' //somehow if I put this inside plugins block it is reporting as not found...so adding outside
集成测试失败并出现错误:
引起:org.springframework.context.ApplicationContextException:无法启动Web服务器;嵌套异常是 org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean。在 org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161)
如果我申请spring.main.web-application-type=none
,那么它会说端口问题
引起:java.lang.IllegalArgumentException:无法在 org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) 中解析值“${local.server.port}”中的占位符“local.server.port”
所以看来 spring.main.web-application-type=none 不行
我在我的 build.gradle 中使用它
gretty {
servletContainer = 'jetty9' // What App Engine Flexible uses
}
bootRun {
if (project.hasProperty('args')) {
args project.args.split(',')
}
}
test {
useJUnitPlatform()
//useJUnit()
}
请问你能帮忙解决这个问题吗?
注意:我可以毫无问题地从 eclipse 运行测试,但从命令提示符失败
./gradlew clean build
我的测试看起来像
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties= {"spring.main.allow-bean-definition-overriding=true"})
@ActiveProfiles("test")
@Import(TestConfiguration.class)
class MyControllerIT {
@LocalServerPort
private int port;
...
}
注意:这是一个多模块项目,构建运行是从父项目文件夹触发的