【发布时间】:2016-08-19 06:00:13
【问题描述】:
今天我安装了 IntelliJ Ultimate 版本 2016.1.1 build 145.597。我后来做的是从 IntelliJ 社区版导入 may 项目。本项目基于 spring-boot 1.3.3。问题是,当我想在 IntelliJ Ultimate 中运行我的应用程序时,application.properties 文件被忽略了,它以默认的 spring 设置开始。当我在 IntelliJ 社区版或命令行中运行相同的项目时,一切正常。当我添加和运行 spring boot 运行配置时,问题仅存在于 Ultimate 版本中,如果我使用 gradle 配置和 bootRun 任务它可以工作。
在 IntelliJ Ultimate 之前我没有使用过。 有谁知道可能出了什么问题?我浪费了 2 个小时的谷歌搜索来解决我的问题,但我什么也没找到。
src/main/resources/application.properties的内容:
server.port=2081
server.ssl.key-store=cfg/certs/keystore.p12
server.ssl.key-store-password=dev
server.ssl.key-alias=alias
server.ssl.key-store-type=PKCS12
spring.datasource.url=jdbc:h2:file:./cfg/db/app;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=none
项目结构:
【问题讨论】:
-
此时application.yml的内容已经无关紧要了。更有趣的是您的项目的文件夹结构。 IE。如果路径真的是 src/resources/application.properties,那么它不是默认的 Maven 结构,你必须确保你在 pom.xml 中正确配置了它。
-
“src/resources”是您的资源目录还是“src/main/resources”(默认标准)?另外,IntelliJ 是否将该目录识别为资源目录?
-
我已经包含了项目结构图像。 @cjstehno 这是默认的(src/main/resources/application.properties)
-
您在导入前是否删除了 .idea 和 .iml 文件夹/文件?另外,你的包不应该在 src/main/java 下吗?目前在src/main下可以看到包kotlin?
-
@MarcoTedone 我在我的项目中使用 Kotlin,所以 src/main/kotlin 很好。我没有删除 .iml 文件夹。我在 IntelliJ Ultimate 中创建了新项目,并从不起作用的项目中简单地复制粘贴了必要的文件。现在它似乎工作正常。谢谢大家的帮助。