Giter VIP home page Giter VIP logo

Spring cloud application/bootstrap.yml error Unknow property name for type Type 'org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties$Source' has no property 'name' about spring-cloud-kubernetes HOT 14 CLOSED

Deimos177 avatar Deimos177 commented on August 16, 2024
Spring cloud application/bootstrap.yml error Unknow property name for type Type 'org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties$Source' has no property 'name'

from spring-cloud-kubernetes.

Comments (14)

wind57 avatar wind57 commented on August 16, 2024

Can you provide a github project as a sample for us to look at and be able to check it out to reproduce the problem? It has to be a minimal reproducible example. Thank you.

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

@wind57 Sure, this is the link for my repository: https://github.com/Deimos177/spring-cloud-graalvm

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

Hello @wind57, there a way more simple example to test: https://github.com/Deimos177/spring-kubernetes isn't working either.

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

If a downgrade to spring cloud version 2021.0.9 the error disapear.

from spring-cloud-kubernetes.

wind57 avatar wind57 commented on August 16, 2024

I am a bit stuck with other things, but I'll get to this one.

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

Okay, don't worry, take your time, i'll be waiting when you can.

from spring-cloud-kubernetes.

wind57 avatar wind57 commented on August 16, 2024

Regarding this : https://github.com/Deimos177/spring-kubernetes

There were things I had to adjust:

  1. your instructions were missing the point about creating the study namespace
  2. include logback as dependency, otherwise there were no logs
  3. include build-image goal in the maven plugin, otherwise I could not build the image locally
  4. your cm.yaml is invalid
  5. You were missing hostPort: 8080, and I could not access your end-point.

I fixed the above in this branch, deployed, then I exec into my k8s cluster:

kubectl get pods -o wide

then issue : curl 10.244.0.8:8080/hello and see : "Hello from kubernetes".

I can not re-produce your issue. Unless you tell me exactly how to do it against that branch I pushed, I can't really help you.

from spring-cloud-kubernetes.

wind57 avatar wind57 commented on August 16, 2024

After you review what I did in that branch, ask yourself where that "message" ("Hello from kubernetes") is really coming from, because you do not have it in cm.yaml under application.yml (again, in that branch I pushed). So your example is kind of miss-leading to me. Nevertheless, I'll gladly wait for your feedback for me to understand how to re-produce that issue, if there is any issue at all :)

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

I merged your PR, yeah a configure the cm.yaml with message=${MESSAGE} instead message: ${message}.
This make the application work, but the context-path isn't working properly, but i've made some changes in the project and seens to work as expected.

about the docker image, i build the project with a custom image with de Dockerfile in the root, because a need some customizations that the default spring image builder don't provider.

i changed the spring-cloud-kubernetes dependency to this:

org.springframework.cloud
spring-cloud-starter-kubernetes-config
1.0.2.RELEASE

and the error disapear.
i added the context-path in the application.yml instead the configmap, inject as an envrioment var and then it worked.
i'll commit my changes and try again later with the spring-cloud-kubernetes default starter, because with it the error come back.

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

Hello, i'm here again, so, i made some changes in the source project of this issue, using the starters from the oficial docs from spring cloud, ignoring the error from the yaml and trying to deploy the application in my minikube cluster, my app is unable to load the spring properties from configmap, and the error reported in this issue persist.
you can check this project https://github.com/Deimos177/spring-cloud-poc and reproduce the issue from there.

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

I tried many solutions, my last try was read the config properties from mounted file in /etc/config/application.yml, but the none of my properties have being loaded, is extremely strange, because if a define some custom property as message: ${MESSAGE}, the configmap propertySource just work, but if i use some of the default spring properties as:

spring:
  application:
    name: cloud-jpa
  datasource:
    password: ${DB_PASSWORD}
    url: ${DB_URL}
    username: ${DB_USER}
  jpa:
    generate-ddl: true
    hibernate:
      ddl-auto: update
    show-sql: true
  profiles:
    active: dev

none of these are loaded.

from spring-cloud-kubernetes.

wind57 avatar wind57 commented on August 16, 2024

I'll take a look in the upcoming days at this. thank you

from spring-cloud-kubernetes.

Deimos177 avatar Deimos177 commented on August 16, 2024

Hello, i think this is the last update,i made several changes in the project and finally it worked.
one of these is in the pom.xml to the following format:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.2.2</version>
		<relativePath />
	</parent>
	<groupId>br.com.deimos</groupId>
	<artifactId>cloud-jpa</artifactId>
	<version>1.0.4</version>
	<name>cloudjpa</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>21</java.version>
		<spring-cloud.version>2023.0.0</spring-cloud.version>
		<log4j2.version>2.17.1</log4j2.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springdoc</groupId>
			<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
			<version>2.3.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.mysql</groupId>
			<artifactId>mysql-connector-j</artifactId>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.glassfish.jersey.inject</groupId>
			<artifactId>jersey-hk2</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-kubernetes-fabric8-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-kubernetes-fabric8</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-bootstrap</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

and cleaned the application.yml and inserted all in the bootstrap.yml to looks like this:

spring:
  application:
    name: cloud-jpa
  cloud:
    kubernetes:
      config:
        enabled: true
      reload:
        enabled: true
        monitoring-config-maps: true
        strategy: refresh
        mode: event

then it works like magic hehehehe.
Thanks for all the support during this time and if you want to look at my project feel free,
One more time, thanks a lot for all!!!

from spring-cloud-kubernetes.

wind57 avatar wind57 commented on August 16, 2024

well as long as it works for you, we are happy too :) feel free to close the issue then

from spring-cloud-kubernetes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.