I have a spring MVC application and I would like to deploy it to Heroku. I keep getting this no main manifest attribute in .jar every time. Spring MVC doesn't have a main method that I can specify to manifest. How could I fix this issue and deploy it? I am running out of ideas.
Error from Heroku:
2022-01-15T11:41:11.336214+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=47818 -jar app.jar`
2022-01-15T11:41:12.129299+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-01-15T11:41:12.133003+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2022-01-15T11:41:12.219291+00:00 app[web.1]: no main manifest attribute, in app.jar
2022-01-15T11:41:12.335236+00:00 heroku[web.1]: Process exited with status 1
2022-01-15T11:41:12.459762+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-15T11:41:17.000000+00:00 app[api]: Build succeeded
Procfile contents:
web: java $JAVA_OPTS -Dserver.port=$PORT -jar app.jar
build.gradle contents:
plugins {
id 'java'
id 'org.gretty' version '3.0.6'
}
group 'org.example'
version '1.2'
gretty {
contextPath = '/'
}
jar {
manifest {
attributes("Implementation-Title": "Gradle",
"Implementation-Version": archiveVersion
)
}
}
repositories {
mavenCentral()
}
def springVersion = "5.3.10"
dependencies {
implementation('com.github.jsimone:webapp-runner:8.5.11.3')
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
implementation group: 'com.fasterxml.jackson.core',
name: 'jackson-databind',
version: '2.12.5'
implementation group: 'org.hibernate',
name: 'hibernate-validator',
version: '6.2.0.Final'
implementation group: 'org.hibernate',
name: 'hibernate-core',
version: '5.5.8.Final'
implementation group: 'org.springframework',
name: 'spring-orm',
version: springVersion
implementation group: 'org.postgresql',
name: 'postgresql',
version: '42.2.23'
implementation group: 'org.springframework',
name: 'spring-jdbc',
version: springVersion
implementation group: 'org.springframework',
name: 'spring-webmvc',
version: springVersion
implementation group: 'org.springframework',
name: 'spring-context',
version: springVersion
compileOnly group: 'org.projectlombok',
name: 'lombok',
version: '1.18.20'
annotationProcessor group: 'org.projectlombok',
name: 'lombok',
version: '1.18.20'
}
test {
useJUnitPlatform()
}
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)