I had a tough time to set the port of a Grails project to something other than 8080. The project was set up with Gradle. I tried all the ways I can think of and found on Google but it does not work. The methods I tried include
./gradlew run -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew run-app -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew grails-run-app -PgrailsArgs="-Dgrails.server.port.http=9090"
./gradlew run -Dgrails.server.port.http=9090
./gradlew -Dgrails.server.port.http=9090 run
./gradlew grails-run-app -PgrailsArgs="--port=9090"
as well as out the grails.server.port.http
property in build.properties
, Config.groovy
and build.grade
. None works. It is hard.
Probably grail run-app
may work with one of the above option (also using BuildConfig.groovy
). But "grails run-app" always resulted a resolving error for org.aspectj:aspectjweaver:1.8.5
. I don't see how to get around this way either.
Any help will be greatly appreciated.
You can also set port like this
-Dgrails.server.port=9090
when you start server using Gradle. It works for me
You are using incorrect property name I guess i.e. grails.server.port.http
. It should be server.port
.Hence try ... -Dserver.port=8256
etc.
Also, you could specify it in your build.gradle task which you are using to run your application as below. For example you are doing it for springboot application using gradle bootRun.(I actually don't have much working experience in grails 3.0 but have in springboot)
bootRun {
systemProperty 'server.port', '8086'
}
This will run your application on 8086 port.
In general, you could try
gradle your_task_to_run_app -Dserver.port=your_port
Also, if you have application.yml in grails 3 app(as grails 3 uses gradle and springboot.If not present you should be able to create one) then do it like below:
app:
name:Springboot+Config+Yml+Demo
version:1.0.0
settings:
counter:1
---
spring:
profiles:development
server:
port: 9001
security:
user.name: 'default'
user.password: 'default'
Let me know it works or not as haven't tried but pretty sure that it will work.
Edit: More this should help! Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With