Reputation: 191
I have an issue while deploying my Spring boot app to Heroku.
The error while pushing the app to Heroku master is:
remote: [INFO] Changes detected - recompiling the module!
remote: [INFO] Compiling 18 source files to /tmp/build_79201803/target/classes
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] COMPILATION ERROR :
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/post.java:[15,8] class Post is public, should be declared in a file named Post.java
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/user.java:[12,8] class User is public, should be declared in a file named User.java
remote: [INFO] 2 errors
remote: [INFO] -------------------------------------------------------------
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 16.300 s
remote: [INFO] Finished at: 2020-08-11T11:09:38Z
remote: [INFO] ------------------------------------------------------------------------
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project springblog: Compilation failure: Compilation failure:
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/post.java:[15,8] class Post is public, should be declared in a file named Post.java
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/user.java:[12,8] class User is public, should be declared in a file named User.java
remote: [ERROR] -> [Help 1]
remote: [ERROR]
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote: [ERROR]
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
remote:
remote: ! ERROR: Failed to build app with Maven
remote: We're sorry this build is failing! If you can't find the issue in application code,
remote: please submit a ticket so we can help: https://help.heroku.com/
remote:
remote: ! Push rejected, failed to compile Java app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
The error here specifies that my User
and Post
models file name starts with lowercase letters.
But my file structure is:
I do not think the error is in the Models, and I am not able to find out the issue.
Upvotes: 2
Views: 1685
Reputation: 39
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
pom.xml
.git add .
git commit -m "Pom Changed"
git push heroku master
Upvotes: 0
Reputation: 66
I solved mine by changing java version 11 to 8(In pom.xml).
From:
<properties>
<java.version>11</java.version>
</properties>
To:
<properties>
<java.version>8</java.version>
</properties>
Upvotes: 3
Reputation: 2797
In your screenshot, the file name starts with a capital letter, but
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/post.java:[15,8] class Post is public, should be declared in a file named Post.java
remote: [ERROR] /tmp/build_79201803/src/main/java/com/pukitbanta/springblog/model/user.java:[12,8] class User is public, should be declared in a file named User.java
the file name displayed in the error message is in lower case.
Please check again for lowercase letters. If they are in lowercase, please correct them as follows:
post.java
to Post.java
user.java
to User.java
If it doesn't make sense to rename those files, it's probably a problem with your Git settings.
see: https://stackoverflow.com/a/46670520/1979953
It WAS a case-sensitive issue. The problem is that I didn't know that GIT is not looking for case-sensitive changes in the file.
You can check your git configuration:
$ git config -l | grep ignorecase
The core.ignorecase
is the one we need this time.
If core.ignorecase
is true
, Git will ignore case differences; if false
, Git will recognize the difference. So you need to set false
.
Then let Git recognize the changes and deploy them to Heroku again.
To update the core.ignorecase to either true
or false
run:
git config core.ignorecase true
or
git config core.ignorecase false
.
Upvotes: 2