statistics,spring-boot,ehcache , ehCache Statistics with spring boot

ehCache Statistics with spring boot


Tag: statistics,spring-boot,ehcache

I have spring boot application with ehcache as below

public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {

    EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
    return ehCacheManagerFactoryBean;

public EhCacheCacheManager cacheManager() {
    return new EhCacheCacheManager(ehCacheManagerFactoryBean().getObject());

I also put @EnableCaching on root configuration file

for ehcache.xml i have the below

<ehcache xmlns:xsi=""
 updateCheck="true" monitoring="autodetect" dynamicConfig="true">

<diskStore path="" />

<defaultCache maxEntriesLocalHeap="10000" eternal="false"
    timeToIdleSeconds="120" timeToLiveSeconds="120" maxEntriesLocalDisk="10000000"
    diskExpiryThreadIntervalSeconds="120" statistics="true">

<cache name="mediumCache"
       memoryStoreEvictionPolicy="LFU" statistics="true"

<cache name="highCache"
       memoryStoreEvictionPolicy="LFU" statistics="true"


Every thing is good and my cachable function are working good , now i want to see the statistics with spring-actuator in metric .

How can we do that ?


If you can afford to use a snapshot release of spring boot this feature is being added to 1.3.0. Right now you won't get that in 1.2.X


Spring: @NestedConfigurationProperty List in @ConfigurationProperties

Hi I am trying to get the following configuration up and running. @ConfigurationProperties(prefix="my") public class Config { @NestedConfigurationProperty private List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(); public List<ServerConfiguration> getServers() { return this.servers; } } @ConfigurationProperties(prefix = "server") public class ServerConfiguration { private String name; private String description; } So, I want to...

Possible to use Spring Boot 1.3.0.M1 with Spring Cloud?

I'd like to be able to start using Spring Boot 1.3.0.M1 (and by extension Spring 4.2.0.RC1) along with Spring Cloud (config server, eureka, ribbon, feign, and zuul). I'm using a gradle build, so initially I was using the dependencyManagement plugin like this: dependencyManagement { imports { mavenBom "" } }...

How to run flyway:clean before migrations in a SpringBoot app?

I am using Springboot and Flyway. The migrations work just fine but I wanted to be able perform a clean flyway command when the application context gets loaded with test profile. Is it possible to configure SpringBoot to do clean and then migrate if active profile is test?...

Error while setting targetConnectionFactory in UserCredentialsConnectionFactoryAdapter Spring 4

We are receiving a compilation error in the following code, while trying to set the targetConnectionFactory. According to the example given in Spring 4 documentation for UserCredentialsConnectionFactoryAdapter, the setTargetConnectionFactory() method takes the object of JndiObjectFactoryBean as an argument. But, looks like the JndiObjectFactoryBean hasn't implemented the 'ConnectionFactory' interface, which is...

Spring Boot War file gets 404 on ec2

I put together a simple Eclipse Spring Boot Rest program. Just a couple of endpoints that return some stings. I am building it with the Eclipse Gradle plug-in. No problems, it runs fine in the Eclipse provided Tomcat instance. I also ran it on a native windows Tomcat. I deployed...

Spring Boot REST display id of parent only in a JSON response

Assume I have the following class: public class ChildEntity { ... @ManyToOne private ParentEntity parent; ... } Now, I have a REST endpoint that retrieves a child entity object from the database, thus my JSON is the following: {"id": "123", "name":"someName", "parent": { //parent fields here } ... } I...

Why is my Spring Boot autowired JPA Repository failing JUnit test?

My JUnit test is failing with the following error: "java.lang.IllegalArgumentException: Could not find field [userRepository] of type [null] on target [[email protected]]" Here is the Test class: @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = App.class) @WebAppConfiguration @IntegrationTest public class UserResourceTest { @Autowired private UserRepository userRepository; private MockMvc restUserMockMvc; @Before public void setup() { UserResource userResource...

How to access entity manager with spring boot and spring data

How to get access to the entity manager in the repository when we use spring boot and spring data? Otherwise, i will need to put my big query in annotation, i would prefer to have something clear... then a long text....

Mock class inside REST controller with Mockito

I have a spring-boot application which exposes a REST interface via a controller. This is an example of my controller: @RestController public class Controller { @Autowired private Processor processor; @RequestMapping("/magic") public void handleRequest() { // process the POST request processor.process(); } } I am trying to write unit tests for...

getting 401 to access http://localhost:8080/oauth/token

I am hitting one end point from my angularjs client app to login when I am doing that one I am getting the following ERROR in browser console OPTIONS http://localhost:8080/oauth/token XMLHttpRequest cannot load http://localhost:8080/oauth/token. Invalid HTTP status code 401 It's server side code to accept CORS from the client. @Component...

Removing a prior sample while using Welford's method for computing single pass variance

I'm successfully using Welford's method to compute running variance and standard deviation as described many times on Stack Overflow and John D Cook's excellent blog post. However in the stream of samples, sometimes I encounter a "rollback", or "remove sample" order, meaning that a previous sample is no longer valid...

How to not-abbreviate the source class name in spriing-boot's loggger name?

When I run a spring-boot application, it shows the following log: 2014-03-05 10:57:51.702 INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] The logger name is abbreviated for the following: org.springframework.boot.context.embedded.FilterRegistrationBean How can I show the full source class name for it? Thanks!...

How do I limit the amount of times a JMS DefaultMessageListenerContainer will retry a message in ActiveMQ?

How do I limit the amount of times a JMS DefaultMessageListenerContainer will retry a message with SpringBoot and ActiveMQ.( I know we can achieve this using JMSXDeliveryCount property in IBM MQ messageListener).

How to apply HandlerInterceptor to Spring Boot Actuator endpoints?

I'm working with Java 8 and Spring 1.2.3 to build an application running inside a Tomcat 7 container. I do intercept every single call to my web application using a very simple HandlerInterceptor, that logs the overall time taken to create a response and the return code for every request....

spring boot switching from in-memory database to persistent database

I have developed my web-application using spring-boot and spring-data-jpa and and in-memory database, and I have a couple questions: how can i now switch to a persistent, let's say, MySQL database? What do I have to change in my configuration? Can spring-boot set a database up for me with a...

Extract data from excel to mysql in java

I want to extract data from excel to mysql but at the beginning i want just to read the file so i use the code below : @RestController public class ExtractDataController { protected String[] celluls; @RequestMapping(value = "/readExcel", method = RequestMethod.GET) public String processExcel() { try { InputStream ExcelFileToRead =...

Getting a lost Sentinel error message for Redis

I am running a spring boot service using spring data redis and here is the following configuration. The service seems to work but I am seeing a stream of Lost Sentinel messages in the logs. The sentinel nodes are reachable form the VM where I am running the service. I...

Can't use scipy stats function on nested list

I've been trying to scipy.mstats.zscore a dataset that is intentionally organized into a nested list, and it gives: TypeError: unsupported operand type(s) for /: 'list' and 'long' which probably suggests that scipy.stats doesn't work for nested lists. What can I do about it? Does a for loop affect the nature...

Spring boot war file deploy on Tomcat

I use Spring Boot 1.2.4.RELEASE with gs-rest-service source file. I got: - - [18/Jun/2015:09:59:25 +0300] "GET /gs-rest-service-0.1.0/ HTTP/1.1" 404 1021 There are no other exceptions in Tomcat logs. I have read related questions, but my test doesn't run. Spring Boot War deployed to Tomcat I have read howto-create-a-deployable-war and...

Trouble with Login using Spring Boot and JDBC Security

My build.gradle file: task wrapper(type: Wrapper) { gradleVersion = '2.4' } buildscript { repositories { mavenCentral() maven { url "" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE") } } apply plugin: 'java' apply plugin: 'spring-boot' repositories { mavenCentral() maven { url "" } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-jdbc")...

Springboot REST application should accept and produce both XML and JSON

I am working on Springboot REST API. My application should consume and produce both XML and JSON. I came across the Jackson json Xml dependency. <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> <version>2.5.4</version> </dependency> I added this in my pom.xml. Now I am able to accept xml input but the values are null when mapped...

How to explain a higher percentage of point variability using kmeans clustering? [closed]

I'm doing some kmeans clustering: Regardless of how many clusters I choose to use, the percentage of point variability does not change: Here's how I am plotting my data: # Prepare Data mydata <- read.csv("~/student-mat.csv", sep=";") # Let's only grab the numeric columns mydata <- mydata[,c("age","Medu","Fedu","traveltime","studytime","failures","fam mydata <- na.omit(mydata) #...

How to handle form submission in HTML5 + Thymeleaf

I have to submit a form with around 30 input parameters(text, select, datepicker ). The fields are mapped to two classes. How to map each field to get the value in the controller. HTML: <form id="searchPersonForm" action="#" th:object="${person}" method="post"> <input type="text" class="form-control" id="person_id" th:field="*{person_id}"></input> <input type="text" class="form-control" id="child_id" th:field="*{child_id}"></input> </form>...

Histogram-like summary for interval data

How do I get a histogram-like summary of interval data in R? My MWE data has four intervals. interval range Int1 2-7 Int2 10-14 Int3 12-18 Int4 25-28 I want a histogram-like function which counts how the intervals Int1-Int4 span a range split across fixed-size bins. The function output should...

How should I use @Cacheable on spring data repositories

When using, for example, MongoRepository there are some methods which I would like to mark as @Cacheable such as insert(entity) or findOne(id). Since its spring repository and not mind, how should I use @Cacheable on those methods?

Adding external static files (css, js, png …) in spring boot

Background I have a spring boot application which has the logo.png file added to the static folder of the resource file, which is eventually built into the jar file which is used in the execution. This jar application need to be run in multiple instances for different clients. So what...

Dynamic fields thymeleaf list iteration

I'm getting a really weird error ! while iterating on list thymeleaf identified index as a property of my bean and not an index value ! <div th:each="phoneStat : *{phones}"> <select th:field="*{phones[__${phoneStat.index}__].variety}" > <option> </option> </select> <div class=" input-field col s4" > <input th:field="*{phones[__${phoneStat.index}__].number}" th:id="${'phonenumber-'+ phones[__${phoneStat.index}__]}" type="text" class="validate" /> <label...

set an annotation attribute from an environment variable?

I'm trying to set an annotation value from an environment variable: @Configuration @ComponentScan @EnableAutoConfiguration @EnableScheduling class Application { @Scheduled(cron = "${DB_CRON}") def void schedule() { ... } public static void main(String... args) {, args) } ... } However, I get the following compile time error: Attribute 'cron' should have...

spring-boot integration testing using rest-assured

I have been struggling with the issue of starting the H2 db in my tests. This is how the tests are annotated - @SpringApplicationConfiguration(classes = ServiceApplication.class) @WebAppConfiguration @IntegrationTest("server.port:8084") @PropertySource("") public class testSerivce{ //test scenario } The in memory db H2 is used and this is how its setup in application...

Spring Boot extending CrudRepository

I'm using Hibernate in a Spring Boot app. I'm making a new CrudRepository for all my Model objects, to do basic CRUD tasks. They look like this: @Repository public interface FoobarCrudRepo extends CrudRepository<Foobar, Long> { } But then I always need to do some additional things, like custom search queries...

Not Able to Resolve View Using Spring boot

I have put all jsp on classpath in views folder. Folder structure is : src/main/resources/ src/main/resources/static/ src/main/resources/static/views/ src/main/resources/static/views/*.jsp src/main/resources/static/views/*.png I am able to retrieve images file from static folder. But When It comes to jsp I am getting following error. While hitting url:http://localhost:9001/login There was an unexpected error (type=Not Found,...

Matlab: What are the ways to determine the distribution of the data

I have a data set of n = 1000 realizations of a random variable X and is univariate -- X = {x1, x2,...,xn}. Data is generated by varying a parameter on which the random variable depends. For example, let the r.v be Area of a circle. So, by varying the...

Normal probability density function - GSL equivalent in Haskell

I am trying to find the best way to draw from a normal distribution. I want to be able to use the normal probability density function (and its cumulative) in Haskell. To put it simply, I want to use the functions on this page without using the GSL binding... I...

Spring Boot - How to kill current Spring Security session?

Currently I know that my setup is working because I was able to login properly using the basic HTTP authentication. I used these properties: security.basic.enabled=true security.user.password=1qaz2wsx security.user.role=USER However, I want to relogin again. I tried clearing cookies (I assumed it was saved there), I checked my local/session storage and...

How to Fetch Data using Spring Data

Hey i want to create a repository extending JpaRepository and fetch result without writing actual query, In my example i have 2 tables Book and Author mapped by many to many relationship, suppose i want to fetch list of books by a particular author_id, since in my book entity, i...

how to: Separate a continuous variable by % proportions?

I have a continuous variable (in this case, fees spent). How do I determine % spending cutoffs? i.e. how do I know what dollar amount separates the bottom 50% from the top 50% (similarly for any other % I may be interested in). Thank you very much for any help

Spring Cloud Config Globals

I have a scenario where I need to set some properties globally for several applications. Is there support for default or global configs in spring cloud config? Example: setting=global_setting something_else=app_setting prop=different_app_setting Here I would want for "myapp" to have setting set. Any help would be greatly appreciated....

disable RabbitAutoConfiguration programmatically

Is there a programmatic(properties based) way of disabling RabbitAutoConfiguration in spring boot (1.2.2). Looks like spring.rabbitmq.dynamic=false disables just the AmqpAdmin but not the connection factory etc. We want a model where app properties might be sourced from spring cloud config (includes control bus) or via -D jvm args. This decision...

Disaggregate one row of data to multiple rows

Goodafternoon! I am having some trouble with my dataset. I am using a Google AdWords export for data analysis and I want to fit a logit regression model to the data to determine whether an experiment I have conducted impacts the conversion. The problem is that the data is aggregated...

Spring framework unable to start embedded container

I'm following Spring in Action 4th Edition Chapter 5, but I'm stuck at the very first example. Here is my Eclipse Luna project structure: If I run this project as Spring Boot App, then it throws exceptions: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start...

Spring Data Rest executes query but returns 500 internal Server Error

I am using spring boot and spring data rest and I am facing a 500 internal server error, but no messages are displayed in console. I have the following: public interface ProdutoVendaRepository extends PagingAndSortingRepository<ProdutoVenda, Integer> { @Query("SELECT new, SUM(i.valorMultiplicado)) FROM ProdutoVenda i JOIN i.produto o JOIN o.familia b...

“Icon” (ISOTYPE) charts in R shiny with Javascript

I'm working on a project to build several models for data analysis and reporting using R and the amazing Shiny framework for web development. I'm getting started with R and Shiny but I've had an amazing experience so far, yet, I'd like to get some help in case someone has...

Get a variables value from one dataset if falling in a range defined by two variables in another dataset in R

I have a question regarding dates manipulation in R. I've looked around for days but couldn't find any help online. I have a dataset where I have id and two dates and another dataset with the same id variable, date and price. For example: x = data.frame(id = c("A","B","C","C"), date1...

Precipitation history of a city

Does anyone know, if there's a site with precipitation (amount of rain in mm/inches) history for different cities? I need the data of Helsinki, Finland. I'm currently using Dark Sky Forecast API to get the current precipitation levels, but it doesn't seem to support that with history calls. I'll cache...

How to access spring.application.instance_id programatically?

I have the following content in my "applicationname.yml" file of my Spring Boot/Cloud application. How can i get the value of spring.application.instance_id in my java code ? This "applicationname.yml" file is hosted in the 'Spring Cloud Config Server'. eureka: password: password client: registryFetchIntervalSeconds: 5 serviceUrl: defaultZone: ${${PREFIX:}eureka.credentials.uri:http://user:[email protected]:8761}/eureka/ instance: preferIpAddress: true...

How to make data repository available in spring boot unit tests?

I'm consistently getting NPE on the repository I'm trying to implement. Here's the repo: public interface EmployeeRepository extends CrudRepository<Employee, Long> { Employee findByEmployeeId(String employeeId); } I'm just trying to do a simple integration test to make sure the app is wired correctly: public class EmployeeRepositoryTest extends BaseIntegrationTest { private static...

R: how to use the bpower function to calculate 2-sample binomial test power

library(Hmisc) #10% difference n1 = 30 n2 = 30 n = 60 p1 = seq(0.1, 0.9, 0.1) p2 = p1 + 0.1 > bpower(p1, p2, n, n1, n2, alpha = 0.05) Power1 Power2 Power3 Power4 Power5 Power6 Power7 Power8 Power9 0.9997976 0.9992461 0.9933829 0.9670958 0.8995984 0.7799309 0.6141349 0.4211642 0.2252629 #20%...

Avoid inserting duplicates into MySQL while reading an excel file using spring boot

I am using spring boot to read an Excel file. I read the name of each sheet and insert them into a database. I want to check if the name already exists, before inserting the name of the sheet. I want to only insert the name if it doesn't already...

Jsp list output [email protected]?

I have a list of tweets inside a user and when I iterate through them all I get is the object but not the actual text <c:forEach items = "${tweets}" var="user" ></c:forEach> <h1><c:out value="${user.tweets}" /></h1> </div> how do I get the value of the tweets, they all save as text...

how to Autowire the applicationContext early?

Using spring boot, how to Autowire the applicationContext ? It must be autowired before the call of endpoint() @Configuration @EnableTransactionManagement @EnableAutoConfiguration @ComponentScan({"", ""}) @ImportResource({ "classpath:META-INF/cxf/cxf.xml" }) public class ContextConfig extends SpringBootServletInitializer { @Autowired private static ApplicationContext applicationContext; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return...