I am trying to learn spring boot actuator. I have a simple basic application which runs via main method. It has not tomcat or anything. It has just one class as below
public class StartUp {
public static void main(String... args) throws InterruptedException {
ConfigurableApplicationContext ctx = SpringApplication.run(StartUp.class,
args);
StartUp mainObj = ctx.getBean(StartUp.class);
mainObj.init();
System.out.println("Application exited");
}
public void init() throws InterruptedException {
System.out.println("inside init method");
Thread.sleep(10 * 60 * 1000);
System.out.println("outside init method");
}
}
I have configured spring actuator as below in pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<!-- [3] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I was trying to view the applications health and info, i have configured the below in application.properties
management.port=8091
management.address=127.0.0.1
management.security.enabled=false
endpoints.shutdown.enabled=true
info.app.name=Startup Dashboard
info.app.version=2.0-ALPHA
logging.file=dashboard.log
while trying the url : http://localhost:8091/info
it never gets resolved.
Is it not possible to configure actuator for standalone applications ?
Your application is not a Spring Boot App yet.
One has to use the #SpringBootApplication at the minimum to convert an app into one.
#SpringBootApplication
public class BootadminMsAlphaApplication {
public static void main(String[] args) {
SpringApplication.run(BootadminMsAlphaApplication.class, args);
}
}
is one such simplest example.
Without this, the spring-boot dependency in your classpath have not been asked to do its magical things to make your application smart. The all-in-one annotation brings spring-boot's auto-configuration into play, that configures a lot of good stuff for the app, including Actuators (if in classpath).
It looks like your application isn't a Spring Boot application. It needs to be.
Related
First of all is it a viable thing to embed Activiti into an API type application for use within that application or should Activiti be run standalone?
The error below is due to bean definition but I'm not sure where the beans should be defined and how - if thats correct approach for version 6. Our standards with Springhboot 2 is to annotate beans in java rather than xml context
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-04-10 21:17:43.924 ERROR 19516 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field runtimeService in ma.cvmeeting.workflow.WorkflowApplication$MyrestController required a bean of type 'org.activiti.engine.RuntimeService' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.activiti.engine.RuntimeService' in your configuration.
Process finished with exit code 0
code:
import org.activiti.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
#SpringBootApplication
public class WorkflowApplication {
public static void main(String[] args) {
SpringApplication.run(WorkflowApplication.class, args);
}
#RestController
public static class MyrestController{
#Autowired
private RuntimeService runtimeService;
#GetMapping("/start-process")
public String startProcess() {
runtimeService.startProcessInstanceByKey("Potulerauneoffre");
return "Process started. Number of currently running"
+ "process instances = "
+ runtimeService.createProcessInstanceQuery().count();
}
}
pom.xml:
<project>
<groupId>ma.cvmeeting</groupId>
<artifactId>workflow</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>workflow</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>7-201802-EA</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.h2database</groupId>
<artifactId>h2database</artifactId>
<version>1.0.20061217</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
There are two ways to initialize the engine when you embed it in your spring based application:
1.) let spring initialize it for you so you can use all the engine services right away without need of any configuration. this requires activiti-spring-boot-starter as dependency.
2.) You initialize engine by your self and provide the services beans from #Configuration class. for this you will require only activiti-engine core as dependency
The reason your application cannot find the RuntimeService because you are trying the second approach add the below dependency in your pom.xml and remove the engine one
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
</dependency>
you should follow documentation for more help.
We recommend activiti 7 core if you are planning to use spring boot 2.x and the use of the new APIs. This is great time if you want to get involved with the new APIs and project initiatives
You could write a #Configuration class and define Activiti services, like this :
#Configuration
public class ActivityConfig {
#Autowired
DataSource dataSource;
#Bean
public DataSourceTransactionManager getTransactionManager() {
return new DataSourceTransactionManager(dataSource);
}
#Bean
public ProcessEngineConfigurationImpl getProcessEngineConfiguration() {
SpringProcessEngineConfiguration res = new SpringProcessEngineConfiguration();
res.setDataSource(dataSource);
res.setTransactionManager(getTransactionManager());
return res;
}
#Bean
public ProcessEngineFactoryBean getProcessEngine() {
ProcessEngineFactoryBean res = new ProcessEngineFactoryBean();
res.setProcessEngineConfiguration(getProcessEngineConfiguration());
return res;
}
#Bean
public RepositoryService getRepositoryService() throws Exception {
return getProcessEngine().getObject().getRepositoryService();
}
#Bean
public FormService getFormService() throws Exception {
return getProcessEngine().getObject().getFormService();
}
#Bean
public TaskService getTaskService() throws Exception {
return getProcessEngine().getObject().getTaskService();
}
#Bean
public RuntimeService getRuntimeService() throws Exception {
return getProcessEngine().getObject().getRuntimeService();
}
#Bean
public HistoryService getHistoryService() throws Exception {
return getProcessEngine().getObject().getHistoryService();
}
#Bean
public IdentityService getIdentityService() throws Exception {
return getProcessEngine().getObject().getIdentityService();
}
}
I know there are others questions on this, and I have checked them, but none solves my issue.
Very simple POM, ready:ing my app for use with an embedded web server, simply so I can start it up...
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Very easy Boot class:
#SpringBootApplication
#RestController
public class SpringBootApp {
public static void main(String[] args) {
SpringApplication.run(SpringApplication.class, args);
}
#RequestMapping(value = "/")
public String hello() {
return "Hello World from Tomcat";
}
}
Tried:
Extend the SpringBootServletInitializer class.
Update spring-boot-starter-parent to the latest (2.1.3).
Setting spring.profiles.active=default in application.properties.
Manually inject TomcatWebServerFactory (ugh...) in #Configuration
class.
Run mvn dependency:purge-local-repository and removed /repository dir
from my .m2 dir, fetching all again with mvn clean install -U.
ETC... I do not see why it is not working, I though Spring Boot was supposed to be easy.
Unable to start ServletWebServerApplicationContext due to missing
ServletWebServerFactory bean.
First argument for SpringApplication.run() is expected to be the primary configuration class of your application. In your case it is SpringBootApp.class and not SpringApplication.class. Following would be the correct configuration for your Spring Boot application.
public static void main(String[] args)
{
SpringApplication.run(SpringBootApp.class, args);
}
Today i started a simple application spring boot application. Because i am starting from the scratch, i am using the latest version of SpringBoot: 2.1.0.RELEASE
I would like to use Jersey to use JAX-RS. I have this working for 1.3.6 Spring Boot version, but I am getting the following error:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'requestContextFilter', defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I can't understand where the problem could be because my application at this point is minimalist.
Apparently the bean 'requestContextFilter' is being configured twice but i have no idea where it is configured.
Here is my configuration:
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>pt.msoftware.userauthservice.App</start-class>
<java.version>1.8</java.version>
<docker.image.prefix>${user.name}</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
SpringBoot application class
#SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
** Jersey Config**
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;
import pt.msoftware.userauthservice.rest.UserEndpoint;
import javax.ws.rs.ApplicationPath;
/**
* Created by marco on 31/10/2018.
*/
#Component
#ApplicationPath("/rest")
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(UserEndpoint.class);
}
}
** Endpoint**
import org.springframework.stereotype.Component;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
* Created by marco on 31/10/2018.
*/
#Component
#Path("/user")
public class UserEndpoint {
#GET
public String message() {
return "Hello";
}
}
Can someone spot what I am missing or what might be wrong with my code/config?
Thank you so much
It's a bug in Spring Boot. Thanks for bringing it to our attention. I've opened this issue to track the problem.
If you intend to only use Jersey and JAX-RS, you do not need to use spring-boot-starter-web. It's, essentially, a Spring MVC-based equivalent of spring-boot-starter-jersey. You can, therefore, avoid the problem you're seeing by removing the spring-boot-starter-web dependency from your application.
If you do want to use both Spring MVC and JAX-RS, you can enable bean definition overriding by adding spring.main.allow-bean-definition-overriding=true to your application.properties file in src/main/resources.
I already went through the link: Unable to connect to Command Metric Stream for Hystrix Dashboard with Spring Cloud and tried few options, but nothing worked out for yet.
I am developing Spring Cloud Code + Hystrix + Turbine.
Could you please let me know what is the issue ? I am using Spring Boot v2.0.4.RELEASE.
HystrixDashboardApplication.java
#EnableTurbine
#EnableHystrixDashboard
#SpringBootApplication
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
tollrate-billboard application has the following code
TollrateBillboardApplication.java
#EnableCircuitBreaker
#SpringBootApplication
#EnableEurekaClient
public class TollrateBillboardApplication {
public static void main(String[] args) {
SpringApplication.run(TollrateBillboardApplication.class, args);
}
}
DashboardController.java
#Controller
public class DashboardController {
#LoadBalanced
#Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
#Autowired
private RestTemplate restTemplate;
#HystrixCommand(fallbackMethod = "getTollRateBackup")
#RequestMapping("/dashboard")
public String GetTollRate(#RequestParam int stationId, Model m) {
TollRate tr = restTemplate.getForObject("http://pluralsight-toll-service/tollrate/" + stationId, TollRate.class);
System.out.println("stationId: " + stationId);
m.addAttribute("rate", tr.getCurrentRate());
return "dashboard";
}
public String getTollRateBackup(#RequestParam int stationId, Model m) {
System.out.println("Fallback operation called");
m.addAttribute("rate", "1.00");
return "dashboard";
}
}
bootstrap.properties
spring.application.name=pluralsight-tollrate-billboard
application.properties
server.port=8082
# eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
#http://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/single/spring-cloud.html#_environment_changes
management.endpoints.web.exposure.include=hystrix.stream
CURL Command Result:
curl "http://localhost:8085/clusters"
output
[
{
"name": "PLURALSIGHT-FASTPASS-CONSOLE",
"link": "http://localhost:8085/turbine.stream?cluster=PLURALSIGHT-FASTPASS-CONSOLE"
},
{
"name": "PLURALSIGHT-TOLLRATE-BILLBOARD",
"link": "http://localhost:8085/turbine.stream?cluster=PLURALSIGHT-TOLLRATE-BILLBOARD"
}
]
EDIT-1::, I am using "hystrix-turbine"
#EnableTurbineStream
#SpringBootApplication
public class HystrixTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixTurbineApplication.class, args);
}
}
Now, I'm getting below error:
2018-09-03 22:23:45.808 WARN 2820 --- [nio-8085-exec-5] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:8085/turbine.stream?cluster=PLURALSIGHT-FASTPASS-CONSOLE : 404 : HTTP/1.1 404
2018-09-03 22:23:45.808 WARN 2820 --- [nio-8085-exec-2] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:8085/turbine.stream?cluster=PLURALSIGHT-FASTPASS-CONSOLE : 404 : HTTP/1.1 404
#Sayali I tried recreating the error in my own system and I managed to get it working, here are a few checks you can make:
1) The URL in your 1st screenshot is incorrect. Your stream URL in the Hystrix Dashboard should be:
http://localhost:8085/turbine.stream?cluster=PLURALSIGHT-TOLLRATE-BILLBOARD
The url should be pointing to the port of the dashboard application that has #EnableTurbine annotation in your main class.
2) Check if you are getting a response for:
http://localhost:8082/actuator/hystrix.stream
(use your browser for this)
(this should be coming from the application you have enabled hystrix on using #EnableCircuitBreaker)
If you're getting pings, then atleast your hystrix stream is accessible.
If not,
Check if you have: org.springframework.boot:spring-boot-starter-actuator in dependencies and
make sure you have the below property set in application.properties file of the application that has #EnableCircuitBreaker in the main class:
management.endpoints.web.exposure.include= hystrix.stream, info, health
Check the URL again.
3) Please get the turbine section working before moving to turbine streams, so as of now, you can make the following change:
#EnableTurbine // instead of #EnableTurbineStream
#SpringBootApplication
public class HystrixTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixTurbineApplication.class, args);
}
}
Also, to use TurbineStream:
you might want to have your Hystrix commands push metrics to Turbine.
Spring Cloud enables that with messaging. To do so on the client, add
a dependency to spring-cloud-netflix-hystrix-stream and the
spring-cloud-starter-stream-* of your choice.
refer: http://cloud.spring.io/spring-cloud-static/Finchley.SR1/single/spring-cloud.html#_turbine_stream
I hope this helps. Please comment to help me know if this worked for you.
sorry late reply.
Add following configuration to instance that serve hystrix.stream
hystrix.dashboard.proxyStreamAllowList: '**'
Trying to setup a simple web application scheduler. So here is my configuration:
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>scheduler</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.1.7.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>hello.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
My classes look like below
#Configuration
#EnableAutoConfiguration
#ComponentScan
public class Application implements WebApplicationInitializer {
public static void main(String[] args) throws Exception {
SpringApplication.run(ScheduledTasks.class);
}
public void onStartup(ServletContext arg0) throws ServletException {
SpringApplication.run(ScheduledTasks.class);
}
#Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.setPort(8081);
factory.setSessionTimeout(50, TimeUnit.MINUTES);
return factory;
}
}
#EnableScheduling
public class ScheduledTasks {
#Scheduled(fixedRate = 500)
public void reportCurrentTime() {
System.out.println("Testing successful ");
}
}
But when i try to start the container i see the exception
ERROR 2592 --- [ost-startStop-1] o.s.boot.SpringApplication : Application startup failed
...
...
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:174)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:147)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121)
... 20 more
I tried to follow Spring Boot Testing: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean but in vain.
Kindly suggest, thanks
You are only running ScheduledTasks:
SpringApplication.run(ScheduledTasks.class);
when you should run:
SpringApplication.run(Application.class);
Running ScheduledTasks means that Spring Boot doesn't know about the configuration in Application. Crucially, it means that it doesn't see #EnableAutoConfiguration which is what switches on auto-configuration and, because you have Tomcat on the classpath, creates the embedded Tomcat instance.
I would fix this by moving the #EnableScheduling annotation from ScheduledTasks to Application, running Application.class rather than ScheduledTasks.class, and annotating ScheduledTasks with #Component:
Application.class:
#Configuration
#EnableAutoConfiguration
#ComponentScan
#EnableScheduling
public class Application implements WebApplicationInitializer {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class);
}
// …
}
ScheduledTasks.class:
#Component
public class ScheduledTasks {
#Scheduled(fixedRate = 500)
public void reportCurrentTime() {
System.out.println("Testing successful ");
}
}
Moving #EnableScheduling means that its on a configuration class, where it belongs. Running Application.class means that Spring Boot sees all of its configuration, including enabling component scanning and enabling auto-configuration. Annotating ScheduledTasks with #Component means that it's found by component scanning and its #Scheduled method is detected.
This should get things up and running. I would also correct your pom so that you're not using a mixture of versions of Spring Boot (you have 1.1.6 and 1.1.7 in there at the moment) and get rid of your EmbeddedServletContainerFactory bean in favour of configuring the port and session timeout using application.properties in src/main/resources instead:
application.properties:
server.port = 8081
server.session-timeout = 3000
besides what #Andy Wilkinson pointed out which is true in the OP's case but not in mine
I saw that my spring-boot-starter-tomcat was with
<scope>provided</scope>
( as i was adding a servlet initializer to run it on wildfly) i commented out that bit and removed provided from spring-boot-starter-tomcat dependency and it started working. Adding here just in case some one else has the same issue
My one got fixed using this dependency :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>