我想使用 Docker 容器内的 spring.io.starter 提供的 Maven 包装器构建一个 Spring Boot 应用程序。我的 Dockerfile 是:
FROM openjdk:8-jdk-alpine
# install bash --> commented because I just need /bin/sh which is already provided by the base image
#RUN apk add --no-cache bash
ENV APP_DIR /app
ENV APP app.jar
WORKDIR ${APP_DIR}
COPY . ${APP_DIR}
# ===> HERE THE PROBLEM
RUN /bin/sh -c "./mvnw clean install"
ENTRYPOINT ["java","-jar","chicowa-app.jar"]
EXPOSE 8080
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
/bin/sh: ./mvnw: not found
Run Code Online (Sandbox Code Playgroud)
经过一些研究后我仍然没有找到解决方案。Docker version 18.06.1-ce, build e68fc7a我在 Windows10 pro 上的docker 版本
非常感谢你的帮助。 …
我有一个在 GCP 上运行的 Spring Boot 应用程序(现在 1 年了),我想更新它,但是当我在mvn appengine:run本地运行时出现此错误:
[INFO] GCLOUD: INFOS: javax.servlet.ServletContext log: 2 Spring WebApplicationInitializers detected on classpath
[INFO] GCLOUD: java.lang.IllegalArgumentException: Unable to find the main class to restart
[INFO] GCLOUD: at org.springframework.util.Assert.notNull(Assert.java:198)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.doStart(Restarter.java:277)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.start(Restarter.java:265)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.lambda$immediateRestart$0(Restarter.java:173)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:637)
[INFO] GCLOUD: d?c. 02, 2018 4:30:20 PM com.google.appengine.api.datastore.dev.LocalDatastoreService cleanupActiveServices
[INFO] GCLOUD: INFOS: scheduler shutting down.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.255 s …Run Code Online (Sandbox Code Playgroud) java google-app-engine spring spring-boot google-cloud-platform
我正在使用 Spring Cloud Kubernetes + Spring Cloud Gateway(SCG),但在 GKE 上部署我的应用程序时遇到了一些麻烦。SCG 没有找到 k8s 服务,我仍然收到这个错误:
There was an unexpected error (type=Service Unavailable, status=503).
Unable to find instance for uiservice
Run Code Online (Sandbox Code Playgroud)
uiservice 是 Angular 应用程序。
当我看一看时,.../actuator/gateway/routes我得到了这个结果:
[
{
"route_id": "CompositeDiscoveryClient_gateway",
"route_definition": {
"id": "CompositeDiscoveryClient_gateway",
"predicates": [
{
"name": "Path",
"args": {
"pattern": "/gateway/**"
}
}
],
"filters": [
{
"name": "RewritePath",
"args": {
"regexp": "/gateway/(?<remaining>.*)",
"replacement": "/${remaining}"
}
}
],
"uri": "lb://gateway",
"order": 0
},
"order": 0
},
{
"route_id": "CompositeDiscoveryClient_uiservice",
"route_definition": …Run Code Online (Sandbox Code Playgroud) kubernetes spring-cloud spring-cloud-gateway spring-cloud-kubernetes
现在2个月,我决定根据MVC模式开发一个Web应用程序.
我来自嵌入式程序(C/C++),所以我将逐步学习Java.
到目前为止,我正在手工完成所有应用程序开发,即我将所有Servlet都放在一个包中,将我的JavaBean放在一个包中,将my(JPA)实体放在另一个包中,并将相同的DAO层放在一个包中.到目前为止一切顺利,我明白我在做什么,一切运作良好.
为了" 促进 "开发和更快地做事,我决定使用Spring MVC(我听说这个框架很好)但是在这里我遇到了一些理解Spring Bean概念的问题.
以下是我对此的疑问:
什么是Spring Bean?(我已经读过这个了,但它没有告诉我如何使用它?)(对我来说,一个Bean只是一个简单的Java类,它尊重一些规则但是当我看一个Spring Bean它完全不同时,我看到一些Spring代码在哪里他们的bean返回了一个对象,为什么他们称之为"Bean",我很困惑),所以.
Spring Bean在SpringMVC的工作流程中涉及哪些方面?
应用程序应该在哪里放置Spring Beans?
如何以及何时使用它?
我在我的应用程序的业务部分使用JavaBeans,例如从表单中检索字段,是否可以使用Spring Beans执行相同的操作?
由于Spring Bean的配置似乎遇到困难(因为我无法理解后面的机制)我们可以使用Spring MVC创建一个Web应用程序而不使用单个Spring bean(当然除了DispatcherServlet)?
为什么使用SpringBean而不是Java Bean?
Spring Bean还有什么?
我意识到Spring MVC并不是那么简单,需要掌握很多东西,特别是很多配置.
从哪儿开始?
我应该放弃使用Spring MVC吗?
我在网上搜索了解但我找不到任何能够详细解释的东西.
谢谢.
PS:对不起我的英语,我住在法国.
是否可以使用Spring注释@ModelAttribute而不使用Spring标签来处理表单<form:form...>。我看到了这种方法,但是使用Thymeleaf似乎很复杂(我对此一无所知)。
Spring应该是一个非侵入性框架,所以我的问题是否有替代解决方案?
我有一个由 Keycloak 保护的 Spring Boot 管理应用程序,我定义了一个具有领域角色的用户ACTUATOR。问题是身份验证后 Spring Security 无权访问领域角色。我可以看到授予的权限:Granted Authorities: ROLE_USER, SCOPE_actuator_access, SCOPE_profile'
查看文档,我发现这一部分:基于委派的策略与 OAuth2UserService这是我的配置:
这是我的配置:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure( HttpSecurity http ) throws Exception {
http.csrf().disable().cors().disable();
http.authorizeRequests()
.antMatchers( "/error","/instances", "/**/*.css", "/**/img/**", "/**/third-party/**", "/*.js" )
.permitAll()
.anyRequest().hasRole( "ACTUATOR" )
.and()
.oauth2Login( oauth2 -> oauth2.userInfoEndpoint(
userInfo -> userInfo.oidcUserService( this.oidcUserService() ) ) );
}
// I just copy-paste the doc's code to play with it...
private OAuth2UserService<OidcUserRequest, OidcUser> oidcUserService() { …Run Code Online (Sandbox Code Playgroud) spring-security spring-boot spring-security-oauth2 keycloak spring-boot-admin
我知道我可以定义这样的东西来在我的容器中获取 pod 名称:
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
Run Code Online (Sandbox Code Playgroud)
但是当我运行时: $kubectl get pods
我有一个不同的结果,例如:uipod-5d6795db87-cxxkg对应于<replicatset name>-cxxkg.
是否可以将全名 ( uipod-5d6795db87-cxxkg) 作为环境变量?而不仅仅是 pod 名称 ( uipod)。
非常感谢
spring-boot ×3
java ×2
kubernetes ×2
spring ×2
spring-mvc ×2
docker ×1
dockerfile ×1
forms ×1
keycloak ×1
kubectl ×1
maven ×1
spring-cloud ×1