- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试启动 HelloWorld 应用程序
如果我将它作为 Spring Boot 应用程序运行但 ComponentScan
看不到我的 @RestController
bean,它会完美运行。
我使用 ServletInitializer
,我可以从控制台输出和它进入的 Intellij IDEA Debug模式。 Spring 看到应用程序 bean 但看不到 Controller 。
package test.gcp.hello;
...
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DtmsApiGcpApplication.class);
}
}
所以我有空的src/main/webapp/WEB-INF/web.xml
:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
最小 src/main/webapp/WEB-INF/appengine-web.xml
:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<version>0.0.1</version>
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
</appengine-web-app>
我的 Spring Boot Application 类位于包层次结构的根部,因此所有 @Components
都必须由 Spring 组件扫描器找到。
package test.gcp.hello;
...
@SpringBootApplication
public class DtmsApiGcpApplication {
public static void main(String[] args) {
System.out.println("#######");
SpringApplication.run(DtmsApiGcpApplication.class, args);
}
}
这是 Controller :
package test.gcp.hello.controllers;
...
@RestController
public class NodeController {
@GetMapping(value = "/api/node", produces = "application/json;charset=UTF-8")
public Mono<Node> home() {
return Mono.just(new Node("alias", "The Alias Node"));
}
}
build.gradle:
buildscript {
ext {
springBootVersion = '2.0.0.M5'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
apply plugin: "com.google.cloud.tools.appengine-standard"
group = 'eu.datatile.dtms.gcp'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-webflux')
providedCompile 'com.google.appengine:appengine:+'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
appengine {
tools {
cloudSdkHome = "path/to/google-cloud-sdk"
}
run {
port = 8080
}
deploy {
stopPreviousVersion = true
promote = true
}
}
Google App Engine 标准本地服务器
的控制台输出:
Starting the App Engine local development server...
2017-11-03 19:35:24.932:INFO::main: Logging initialized @567ms
Connected to server
Nov 03, 2017 5:35:25 PM com.google.appengine.tools.development.IsolatedAppClassLoader checkWorkingDirectory
WARNING: Your working directory, (/Applications/IntelliJ IDEA.app/Contents/bin) is not equal to your
web application root (/Users/abc/dev/src/dtms/gcp/dtms-api-gcp/build/libs/exploded/dtms-api-gcp-0.0.1-SNAPSHOT.war)
You will not be able to access files from your working directory on the production server.
2017-11-03 19:35:25.291:INFO:oejs.Server:main: jetty-9.3.18.v20170406
2017-11-03 19:35:26.042:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=540ms
Nov 03, 2017 5:35:26 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
INFO: javax.servlet.ServletContext log: 2 Spring WebApplicationInitializers detected on classpath
...
17:35:26.171 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M5)
2017-11-03 17:35:26.649 INFO 10294 --- [ main] e.d.dtms.gcp.api.ServletInitializer : Starting ServletInitializer on alexanders-mbp with PID 10294 (/Users/abc/dev/src/dtms/gcp/dtms-api-gcp/build/libs/exploded/dtms-api-gcp-0.0.1-SNAPSHOT.war/WEB-INF/classes started by abc in /Applications/IntelliJ IDEA.app/Contents/bin)
2017-11-03 17:35:26.650 INFO 10294 --- [ main] e.d.dtms.gcp.api.ServletInitializer : No active profile set, falling back to default profiles: default
2017-11-03 17:35:26.711 INFO 10294 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@573906eb: startup date [Fri Nov 03 17:35:26 UTC 2017]; root of context hierarchy
2017-11-03 17:35:27.316 INFO 10294 --- [ main] c.g.a.t.development.ApiProxyLocalImpl : javax.servlet.ServletContext log: Initializing Spring embedded WebApplicationContext
2017-11-03 17:35:27.316 INFO 10294 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 605 ms
2017-11-03 17:35:27.499 INFO 10294 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2017-11-03 17:35:27.499 INFO 10294 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-11-03 17:35:27.826 INFO 10294 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-11-03 17:35:27.838 INFO 10294 --- [ main] e.d.dtms.gcp.api.ServletInitializer : Started ServletInitializer in 1.658 seconds (JVM running for 3.474)
2017-11-03 19:35:28.005:INFO:oejsh.ContextHandler:main: Started c.g.a.t.d.j.DevAppEngineWebAppContext@6dfcffb5{/,file:///Users/abc/dev/src/dtms/gcp/dtms-api-gcp/build/libs/exploded/dtms-api-gcp-0.0.1-SNAPSHOT.war/,AVAILABLE}{/Users/abc/dev/src/dtms/gcp/dtms-api-gcp/build/libs/exploded/dtms-api-gcp-0.0.1-SNAPSHOT.war}
...
c.g.a.t.development.DevAppServerImpl : Dev App Server is now running
最佳答案
Spring Boot 不支持使用 Spring WebFlux 进行 WAR 部署。
关于spring - Google AppEngine 标准本地服务器 (Java8) + Spring Boot + WebFlux 没有看到我的@RestController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47102087/
有人可以解释一下 spring-boot-parent 和 spring-boot-starter-parent 之间的区别吗,正如我在下面附加的 GIT HUB 代码链接之一中看到的,他们为 spr
我有与 jersey 框架集成的 Spring Boot 应用程序。 现在,当我尝试运行该应用程序时,它只是停留在 Spring 启动徽标上,之后没有任何 react 。 我也尝试添加 -X ,但徽标
我指的是 Spring Boot 关于 的文档自动配置 和 执行器 模块: 自动配置: Spring Boot AutoConfiguration attempts to automatically
我正在尝试将 apache log4j 集成到我的 Spring boot 应用程序中。这是我的 build.gradle 文件: build.gradle buildscript { rep
使用 Spring Boot Maven 插件的以下命令在生产中启动 Spring Boot 应用程序是否是一个好主意或实践? mvn spring-boot:run 最佳答案 不,这是个坏主意。 您
据我所知,spring boot 和 spring session 为我们提供了一站式自动配置,但是当我的应用程序使用 session redis 和应用程序缓存 redis 时,不是同一个 redi
我希望使用Spring Boot创建一个新的Web应用程序。不幸的是,我的服务器在技术堆栈方面相当有限。它安装了Java 5。 谁能告诉我spring boot是否可以在Java 1.5上运行以及什么
我有3个实体 CarWash(设置Wash) Wash(car_wash_id FK到CarWash) WashComment(wash_id FK到Wash) 有什么办法可以写这个查询 @Qu
我一直在关注this文章。 我正在尝试在Spring-boot应用程序中优雅地处理gRPC错误,的主要目标是能够在gRPC客户端中获取错误状态。 在上面的文章之后,我坚持为异常添加拦截器。如何在Spr
我有一个要使用的自定义log4j布局插件。在IntelliJ中运行或与./gradlew bootRun一起运行时,插件可以正常工作。不使用./gradlew bootJar构建启动jar。 启用-D
我想在给定范围 (5001-5100) 的随机端口上启动 Spring Cloud 应用程序(Spring Boot 1.5.14,Spring Cloud Edgware.SR4)。我知道我们可以使
任何人都可以向我展示或指出不使用 spring boot gradle 插件的 spring boot gradle 项目。 我正在寻找类似不使用 gradle 插件的 spring boot sta
我当时尝试包含上述依赖项之一,但找不到任何区别: spring boot starter web:我可以看到 Flux 和 Mono 类并制作一个响应式(Reactive)休息 Controller
我们一直在为我们的应用程序使用 Springboot 1.X。 现在准备开始一些新的应用程序,想知道我们是应该使用 SpringBoot2.0 还是坚持使用 SpringBoot 1.X? 对一种方式
我希望记录应用程序正在加载 application-profile.propeties 或 application.yml。怎么做。在哪种方法中,我可以听取它并检测它是成功加载还是失败。 最佳答案 您
当我在 pom.xml 中添加简单的 spring-boot-starter-data-jpa 依赖项时,在 pom.xml 文件中出现错误。如果我删除该依赖项,则不会再有错误。我不确定为什么会发生这
我希望记录应用程序正在加载 application-profile.propeties 或 application.yml。怎么做。在哪种方法中,我可以听取它并检测它是成功加载还是失败。 最佳答案 您
我在网上看了很多关于 spring-boot-devtools 的文章和问题,但仍然无法弄清楚为什么它对我不起作用。每次运行我的应用程序时,我都会得到以下信息: 17:54:28.057 [main]
我正在尝试将现有的 Spring 应用程序移植到 Spring Boot。我不使用 spring-boot-starter-data-solr 启动器,但是我的类路径上有 apache solrj (
(这主要是一个历史问题。Pivotal 建议所有论坛讨论都在 StackOverflow 上进行,这就是我在这里问它的原因。) Spring Boot 项目用来证明将应用程序的类和依赖项从可执行 ja
我是一名优秀的程序员,十分优秀!