[英]Heroku Spring boot + Mongo DB on atlas
I am getting Null pointer exception while deploying my application on Heroku, from the exception log我在 Heroku 上部署我的应用程序时从异常日志中收到 Null 指针异常
2021-01-28T23:18:59.561585+00:00 app[web.1]: Caused by: java.lang.NullPointerException: null
2021-01-28T23:18:59.561585+00:00 app[web.1]: at com.mongodb.ConnectionString.<init>(ConnectionString.java:285) ~[mongodb-driver-core-3.11.2.jar!/:na]
2021-01-28T23:18:59.561585+00:00 app[web.1]: at com.mongodb.client.MongoClients.create(MongoClients.java:61) ~[mongodb-driver-3.11.2.jar!/:na]
2021-01-28T23:18:59.561585+00:00 app[web.1]: at com.shop.MongoConfiguration.mongoClient(MongoConfiguration.java:34) ~[classes!/:0.0.1-SNAPSHOT]
2021-01-28T23:18:59.561586+00:00 app[web.1]: at
which looks like the application is not reading my application.properties file看起来应用程序没有读取我的application.properties文件
spring.data.mongodb.uri=mongodb+srv://****
spring.data.mongodb.database=****
The application is working file on local env该应用程序是本地环境中的工作文件
Any idea how to overcome this issue?知道如何克服这个问题吗?
issue solved by adding the below to pom.xml file通过将以下内容添加到 pom.xml 文件来解决问题
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
as maven was ignoring copying the application.properties file inside the java directory因为 maven 忽略了复制 java 目录中的 application.properties 文件
remote: [INFO] Scanning for projects...
remote: [INFO]
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Building e-commerce 0.0.1-SNAPSHOT
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO]
remote: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ e-commerce ---
remote: [INFO]
remote: [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ e-commerce ---
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ e-commerce ---
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] Copying 16 resources
remote: [INFO] Copying 1 resource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.