Closed liuyang2010001256 closed 5 years ago
Please learn how to properly format code and logs.
Can you elaborate what the problem is, what the logs say the error is and how to reproduce it?
my problem is when my application run, it does not find actived config named application-dev.yml, it run with default config named application.yml. and log says No active profile set, falling back to default profiles: default.
my application.yml file
、、、
spring: profiles: active: dev mvc: favicon: enabled: false devtools: restart: enabled: true livereload: enabled: true
logging: level: ROOT: WARN com.longfor: INFO
management: security: enabled: false info: git: enabled: true env: enabled: true endpoints: health: sensitive: false restart: enabled: true shutdown: enabled: true info: enabled: true sensitive: false
、、、
The log has answered your question. You DIT NOT set any active profile.
You should run your app with specify profile by providing environment variable, e.g.
./mvnw.cmd spring-boot:run -D"spring-boot.run.profiles"=dev
it is idea's problem,tk
Hi, My application properties
spring.profiles.active=@spring.profiles.active@ server.port=8000
My pom.xml file
<?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">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>Demo_Docker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Demo_Docker</name>
<description>Demo_Docker</description>
<properties>
<java.version>17</java.version>
<spring.profiles.active>development</spring.profiles.active>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
My Dockerfile
FROM openjdk:17-jdk-alpine ARG JAR_FILE=out/*.jar COPY ./out/artifacts/Demo_Docker_jar/Demo_Docker.jar app.jar EXPOSE 8000 ENTRYPOINT ["java", "-jar", "/app.jar"]
RestController
@RestController public class hello {
@GetMapping("/")
public String greeting() {
return "Greeting Sto";
}
INFO FRON INTELLIJ 17:38:36.217 [main] INFO com.example.demo_docker.DemoDockerApplication -- No active profile set, falling back to 1 default profile: "default"
CAN HELP PLS
APP NOT RUNNING ON DOCKER!
my application run with this error, and when i change config file's name from application-dev.yml to application-ops.yml and change application.yml's active from dev to ops. it run successful,i want to know why? my config:
(please ignore xx)