Spring Integration + Spring Boot Actuator Endpoints not showing up - java

I have been trying to learn more about Spring Boot and I would like to add the Actuator endpoints to my test Spring integration/Spring Boot project. However, it is a plain, CLI Spring integration project--there are no current REST or web services. I'd ideally like to add the ability to view the endpoints with a browser while the jar is running from the command line.
I have been looking through the tutorials and I'm not finding a lot on adding it to a regular project, rather than a web project.
I've added the dependencies (spring-boot-actuator), and can see the endpoints from the jconsole, but I never see a connection to a port on my system (using netstat) and never can navigate there.
Is there a tutorial or something that can show me how to have REST endpoints with a CLI project?
Thank you
newbo

You can monitor and manage your application using JMX instead. See the documentation here.
If you use IntelliJ IDEA, hit CTRL+Space in an application.properties file to see a lot of JMX properties ready for you, one of them being:
endpoints.jmx.enabled=true (true is the default value)

According to Spring Docs, in order to show the endpoint user need to have ACTUATOR role.If you need to access without having the role you need to add the following value to application.properties:
management.security.enabled=false

I think if it isn't a web project, no tomcat servlet will be embedded, therefor you wont be able to browse the actuator endpoints over http
Insert dependency spring-boot-starter-web into your project and it will probably work.

Related

Spring boot actuator in console application

I have a console application using Spring. My application is connecting on a database and a JMS server.
I would like to know at the start up of my application, if it is well connected to the databse and the JMS.
I know that spring-boot-actuator do that efficiently and esealy, but it expose rest endpoints. I would like to know if it's possible to get Spring actuator's beans to get status informations, database and JMS status.
Is it possible ?
Thank you.
About your second question: Yes, springs actuators provide autoconfigured health indicators when they are found on classpath, see this list for more details (datasource and JMS is provided).
But you can also easily implement your own status informations by just implementing HealthIndicator and adding it as a #Component, more details can be found here.
You can expose them either with REST or with JMX, the exposure can be configured via application.properties, details can be found in the docs.
According to the documentation, endpoints can be exposed through HTTP or JMX. By default, Spring will expose actuator endpoints over JMX unless you configure it not to do so.
There is a table showing which endpoints are enabled in JMX and HTTP by default. If you want to enable them on HTTP, there are several security settings you should be aware of before exposing them (see docs link above).
In order to expose actuator endpoints over HTTP, you'll need to include the spring-starter-web start in your build.
Gradle:
compile('org.springframework.boot:spring-boot-starter-web')
Maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Again, check the security settings before doing this. Newer versions of boot should give you a good safe set of defaults.

How to deploy spring boot web application with configurable properties

After researching i learned that the common way to deploy spring boot web applications is as a war file.However,i have a project i made for a company,now i need to send them the project to try it out and they need to be able to configure the application.properties or to be specific the database location and credentials.so my question is do i need to deploy the project in a different way or is there a way to make the war file application properties modifiable later ?
Did you consider Spring Cloud Config Server
https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html.
This is the most elegant way to configure and externalize your properties. If not I would strongly suggest incorporating that component. Plug the config server with your spring boot app without much coding and your application will be much more manageable and extensible.
Spring Boot applications are actually typically packaged as Uber jars with Tomcat embedded. You can accomplish this using spring-boot maven plugin or a similar gradle plugin if need be.
Once in this state the jar can be started normally and you can override configuration properties when invoking it.
java $JAVA_OPTS -Dspring.service.name=my-service -jar /my-service.jar
EDIT: This is not the only way you can solve this problem, and #piy26's answer is an excellent solution for injecting external configuration into an enterprise ready spring boot application. However for the case that your are describing you would need the company to set up there own configuration server, and whats more they will still have to override the configuration server location property so the application will pull properties from their config-server. For your example it seems you need the simplest way to override application properties within the jar.

How to use Spring Boot Activity Rest api in Activity App Ui

I am new to Activity process. I want to used the Activity with spring boot application. So, I want to used the rest api in spring boot and that rest api will be used by activiti-admin.war and activiti-app.war.
So, when I have deployed process from spring boot that will be available in UI and add some Listener while assigning task will be called in my spring boot app.
Can any one help.
Thanks in advance.
It sounds like you are using the version 6 Activiti build.
Both the activiti-app and admin-app already use "a" REST API to communicate to the backend, however it is not the community REST API that will be deployed with your Spring boot application (I assume you are using the Activiti spring boot starter rest).
It is not actually going to be trivial to separate the activiti-app and admin-app UI from the service layer as they are quite tightly coupled, but it is certainly possible.
While I haven't actually attempted it, it may be easiest to take the activiti-app build module (activiti-ui/activiti-app) and separate the client and server portions since the client is now a regular AngularJS application.
Is this what you are looking for?
Thanks,
Greg
I hope you are looking for something like this. It seems they are planning to support activiti app with your own spring boot application in Activiti 7.
If you are able to solve the case, please help with the sample structure. I am bit stuck with same usecase.

Monitor Endpoint using Spring Framework

I'm trying to find an out-of-the-box health check for my spring app. However, I can only find support for Spring Actuator. I'm not able to use Spring Actuator because my application is a Spring application and not a Spring boot app. Is there another library that I could make use of without having to write my own? I would ideally want an endpoint that could possibly give me data about whether my DB is up and possibly some of the java opts passed into that particular node

Where is Spring 3 MVC in REST web-app example download?

I saw springsource.org had not spring 3 in rest web-app sample,where is download?
All Spring samples are on the official SVN repository. The MVC Showcase application should get you started on REST web applications with spring mvc:
svn co https://src.springframework.org/svn/spring-samples/mvc-showcase/ mvc-showcase
If you want to work on the client side, Spring provides RestTemplates for accessing other rest services from your application.
If you use maven you can simply add it to your pom. If not, you can manually download whichever sub-project you need from here.
I haven't found any rest example with spring MVC 3. The #SessionAttributes annotation breaks REST idea.
vn co https://src.springframework.org/svn/spring-samples/mvc-showcase/ mvc-showcase
It's not rest application cause it uses #SessiontAttributes annotation. But REAST requires transfer state via URL
They are now only on github afaik :
https://github.com/SpringSource/spring-mvc-showcase

Categories