- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的主应用程序:
// Application.java
package com.my.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = "com.my")
public class Application
{
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
}
// TestClass.java
package com.my.application;
public class TestClass
{
public TestClass()
{
}
}
//ApplicationConfiguration
package com.my.configuration;
import com.my.application.TestClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
@Configuration
public class ApplicationConfiguration
{
@Autowired
Environment env;
@Bean TestClass getTestClass()
{
System.out.println(env.getProperty("test"));
return new TestClass();
}
}
// pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my</groupId>
<artifactId>test</artifactId>
<version>1.3.0</version>
<packaging>pom</packaging>
<name>test</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.23</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
// src/main/resources/application.yml
test: 123
最佳答案
这与 Maven 有关 - application.properties
当您使用 <packaging>pom</packaging>
时,它不是构建的一部分在您的 pom 文件中 - 因此当您启动应用程序时,该文件不在那里可供读取。
删除 <packaging>pom</packaging>
从你的 pom 开始,你应该很高兴。
关于spring-boot - Spring Boot 不加载 application.yml 配置或?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54839765/
我已经成功创建了我的第一个 django 项目。 我的项目 foo 和 foobar 中有两个应用程序。 我在每个应用程序文件夹中创建了一个名为“fixtures”的文件夹。我没有在我的setting
我遵循了 cap + nginx + unicorn 上的文档,但在理解如何正确进行数据库部署时遇到了一些问题。 /config/database.yml 不应该在 git repo 中(最好) 在/
GitLab server can't start .原因很可能是 gitlab.yml 配置文件不正确。 用什么工具检查yml语法是否正确? 我试过 Notepad++ 和 SublimeText,
我们有一个站点范围的 config.yml 文件,它联系 api key 等... 我的另一个 YML 文件能否访问 config.yml 中的值? 配置文件: development: th
我正在尝试在我的第一个测试应用程序中设置用户和安全管理,但我已经有点迷失了,不知道什么是做什么的。 到目前为止我的设置:Symfony 2.5、SonataUserBundle(以及 FOSUserB
我需要在 application.yml 中使用 yaml anchor 引用和字符串连接对于 Spring Boot 应用程序。动机是重用现有配置而不是复制它们。例如,我们有以下 applicati
我需要将单个 YML 文件拆分为多个 YML 文件: 微服务.yml: #------------------------------------------------------------- #
在我的 Symfony2 config.yml 文件中,我想导入一些我希望收集在单独的 yml 文件中的配置。 我用过: imports: - { resource: parameters.yml }
我是新的 docker 用户。在不同的手册中,我通常发现 docker-compose.yml 文件用于描述 docker 作业,但在 docker 站点上为此目标使用了 docker-stack.y
我不明白这两种在 Symfony2 中设置全局常量的方法之间的区别。是否只能在 config.yml (+configuration.php) 中设置默认值和类型? 最佳答案 参数.yml 文件是所有
在 config.yml 中,我看到了 monolog、web_profiler 等根元素。那些服务可以在 service.yml 中配置吗?换句话说,我在 service.yml 中定义的服务是否可
我阅读了这个文档:https://serverless.com/framework/docs/providers/google/guide/services/ users/ serverless.
我正在从事 CI/CD 项目(使用 circleci 管道),目前,我坚持让我的“create_infrastructure”工作正常工作。下面是作业 # AWS infrastructure
编辑:原始标题“文本环境:”平台“sqlite”不支持函数“year”” 将 beberlei\DoctrineExtensions 合并到测试环境中会产生 Uncaught PHP Exceptio
abc.yml: d_lab: 192.168.1.1 d_location: /ephemeral ema: apple: 10.0.0.1 orange: 10.0.0.2
我的 springboot 应用程序有一些 yml 文件(每个文件用于各种配置文件 - dev、prod)来加载配置。我正在将配置移至数据库。 示例配置如下: admin: id: user05
我有一个大型剧本,它使用多个角色来设置新服务器。我想重新使用剧本,但为了退役阶段而不是调用 role_name/tasks/main.yml 并有很多 when: 语句,我想要告诉 Ansible 调
使用 bookdown 创作文档时,我知道有四个选项可以放置配置选项: _bookdown.yml _output.yml 第一个 .Rmd 的 yaml header 文档 传递给 bookdown
我们希望将我们的 azure pipeline build .ymls 模块化。对于完整的应用程序构建,将包括不同组件的构建 .yml 到主 .yml 中,将它们全部构建在一起。对于单独的组件,我们将
假设我的网站上有一个简单的传统联系表单,我希望它在发送电子邮件时在开发环境中使用主题“Test: (subject_field value)”,在生产环境中使用“(subject_field_valu
我是一名优秀的程序员,十分优秀!