I am totally new to Spring and started to do the official guides from this site: https://spring.io/guides
I\'d like to do this guide: https://spring.io/guides/gs/sch
A scan of the @SpringBootApplication
show that it includes the following annotations:
@Configuration
@ComponentScan
@EnableAutoConfiguration
So you could do this too:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(ScheduledTasks.class, args);
}
}
Probably you missing @SpringBootApplication in your spring boot starter class.
@SpringBootApplication
public class LoginSecurityAppApplication {
public static void main(String[] args) {
SpringApplication.run(LoginSecurityAppApplication.class, args);
}
}
I've had similar problems when the main method is on a different class than that passed to SpringApplcation.run()
So the solution would be to use the line you've commented out:
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I had a similar issue and the problem was a broken maven repo jar file. In my case, the tomcat-embed-core
jar file was broken. So I removed it from the maven repo and refreshed it to download again.
I had multiple application classes in one Spring Boot project which had the web started included and wanted to avoid it configuring a web environment for one of them so I manually configured it as below:
@SpringBootApplication
public class Application
{
public static void main(String[] args)
{
new SpringApplicationBuilder(Application.class)
.web(false)
.run(args);
}
}
UPDATE for Spring Boot 2 and above:
@SpringBootApplication
public class Application
{
public static void main(String[] args)
{
new SpringApplicationBuilder(Application.class)
.web(WebApplicationType.NONE)
.run(args);
}
}
check your pom.xml is exists
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
I've had a problem like this;For lack this dependency