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:
server.port: 8088
management.port: 9988
spring:
application:
name: xxx
cloud:
consul:
enabled: false
discovery:
fail-fast: false
management:
security:
enabled: false
abc:
web:
xxljob:
enabled: true
admin:
addresses: xxx
executor:
appname: cmdb
ip:
port: 9998
accessToken: 53aa095311
logpath: D:\download
logretentiondays: -1
data:
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
mybatis:
typeAliasesPackage: com.xx.devops.xx.business.entity
mapperLocations:
classpath: com/xx/devops/xx/fetcher/cmdb/repo/xml/*.xml
mapper:
notEmpty: true
database:
primary: master
connection:
master:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://xx/mysql?useSSL=false&characterEncoding=UTF-8
username: root
password: xx
hikari:
auto-commit: true
connection-timeout: 10000
idle-timeout: 600000
max-lifetime: 1800000
minimum-idle: 10
maximum-pool-size: 10
cmdb.url: xx
cmdb.params: cmdb/params
cmdb.headers: cmdb/headers
(please ignore xx)
Comment From: spencergibb
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?
Comment From: liuyang2010001256
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
、、、
Comment From: PeichengLiu
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
Comment From: liuyang2010001256
it is idea's problem,tk
Comment From: stoiandelev
Hi, My application properties
spring.profiles.active=@spring.profiles.active@ server.port=8000
My pom.xml file
<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!