As the title suggested, i'm having trouble configuring the port for a micronaut server. I would like the port to be configured from the CLI or from a properties file, not from inside the java application (i don't want to rebuild the project each time i want to change the port). I have seen that using spring the following command can be used:
java -jar server.jar --server.port=8888
Is there any similar CLI command for micronaut? Or can someone help me out configure a properties file to change the port?
As mentioned in Run Micronaut service on port provided from commandline there are these two opions.
$ java -Dmicronaut.server.port=7070 -jar foo-0.1-all.jar
or
$ MICRONAUT_SERVER_PORT=7070 java -jar foo-0.1-all.jar
This is the solution i was searching for. However, only the first option worked for me. Thank you PeterMmm!
Related
I'm being able to run a Spring Web Application on browsers by executing an Uber/Fat JAR using java -jar JAR-file command but I don't know whether I can specify the port number to run on like in Angular using --port?
you can use server.port property in command line to specify the port number.
java -jar JAR-file --server.port=8083
or
java -jar -Dserver.port=8083 JAR-file
I have a h2db jar which i want to run on port other than 8082.
I tried java -jar -Dserver.port=XXXX but it is still running on 8082.
Is there any way to run it on other port?
You can use
java -jar h2-*.jar -webPort 9999
where h2-*.jar is the name of H2's jar file and 9999 is a port number.
There are also -tcpPort, -pgPort and other parameters.
If you want to start the web server only without other open ports for JDBC and ODBC clients and open a browser window, use
java -jar h2-*.jar -web -webPort 9999 -browser
I think the parameter to be used is webPort and not server.port.
Also you might have to provide this parameter in the .h2.server.properties file as stated in the documentation:
http://www.h2database.com/html/tutorial.html#console_settings
I am trying to add my java jar application to Ubuntu as service so that when the Ubuntu server is restarted I dont need to manually run the jar command to run my application. At present I have to run this cmd on the terminal
java -jar myapp.jar -conf conf.json.
I came accross this link which would have solved my problem but for some reason the service is not running when i run the service as described in that website.
http://www.jcgonzalez.com/ubuntu-16-java-service-wrapper-example
Can someone please help me!!
I think your bash script should have "nohup" like this:
nohup java -jar myapp.jar -conf conf.json &
I'm running a Spring Boot application and using the Netflix OSS Spring Cloud framework. We are running a Eureka instance and have a service that is trying to register. When our service registers to Eureka it uses IP of the wrong port name. To fix this we have added:
spring.cloud.inetutils.ignoredInterfaces=eth0
This works great when we pass this from the command line, but when we move this into a profile configuration it doesn't work but all other configuration of the profile is picked up.
So for example this will work:
java -jar service.jar --spring.cloud.inetutils.ignoredInterfaces=eth0
and this will NOT work:
java -jar service.jar --spring.profiles.active=localvm
where application-localvm.properites contains:
spring.cloud.inetutils.ignoredInterfaces=eth0
Look you have to add -D argument before the main class or jar archive.
So try this:
java -jar -Dspring.profiles.active=localvm service.jar
For more details check this doc about how to set the active Spring profiles.
I am trying to use the NSSM - the Non-Sucking Service Manager to run Jetty that is included with Solr as a Windows Service. Everything works fine by placing Java.exe in my C:\solr folder and setting up NSSM by pointing to this Java.exe along with the following parameters -Dsolr.solr.home=C:/solr -jar start.jar
You can also run C:\solr\java.exe -Dsolr.solr.home=C:/solr -jar C:/solr/start.jar from the command line without installing the service as a test which works fine.
If I leave Java.exe in the System32 folder though, things will not work and I get a java.lang.ClassNotFoundException for org.mortbay.xml.XmlConfiguration.
I can of course run C:\solr\java -Dsolr.solr.home=C:/solr -jar C:/solr/start.jar as well since Java is in my PATH.
If seems like I need an additional classpath option or something but I don't know?
I ended up using the following in the arguments for NSSM: -Dsolr.solr.home=C:/solr/ -Djetty.home=C:/solr/ -Djetty.logs=C:/solr/logs/ -cp C:/solr/lib/*.jar;C:/solr/start.jar -jar C:/solr/start.jar