Spring Boot 404 on REST API calls only - java

Issue:
I'm working on a Spring-Boot Web Application that needs to be deployed on tomcat (WAR file). When running the application as Java (right click application.java file and run as Java in Eclipse) or running via mvnw.cmd spring-boot:run, everything works PERFECTLY (home page shows, all CRUD operations work).
When I export a WAR file and deploy to tomcat, my static web content and homepage still load fine, but any API calls return a 404 response.
This project was created using Spring Initializr. I've tried exporting via Eclipse war export, and mvnw.cmd package. Placed the WAR file in webapps directory on server and ran.
Directory structure:
Application file:
package com.blank.systemshare;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class SystemshareApplication {
public static void main(String[] args) {
SpringApplication.run(SystemshareApplication.class, args);
}
}
ServletInitializer:
package com.blank.systemshare;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SystemshareApplication.class);
}
}
Controller:
package com.blank.systemshare.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blank.systemshare.exception.ResourceNotFoundException;
import com.blank.systemshare.model.System;
import com.blank.systemshare.repository.SystemRepository;
#RestController
#RequestMapping("/api/v1/")
public class SystemController {
#Autowired
private SystemRepository systemRepository;
// get systems
#GetMapping("systems")
public List<System> getSystems() {
return this.systemRepository.findAllByOrderByVersionDesc();
}
// create system
#PostMapping("systems")
public System createSystem(#RequestBody System system) {
return this.systemRepository.save(system);
}
// update system
#PutMapping("systems/{id}")
public ResponseEntity<System> updateSystem(#PathVariable(value = "id") Long systemId,
#Valid #RequestBody System systemDetails) throws ResourceNotFoundException {
System system = systemRepository.findById(systemId)
.orElseThrow(() -> new ResourceNotFoundException("System not found - ID: " + systemId));
system.setVersion(systemDetails.getVersion());
system.setUrl(systemDetails.getUrl());
system.setCredentials(systemDetails.getCredentials());
system.setFrameworks(systemDetails.getFrameworks());
system.setFw_credentials(systemDetails.getFw_credentials());
system.setNotes(systemDetails.getNotes());
system.setOwner(systemDetails.getOwner());
return ResponseEntity.ok(this.systemRepository.save(system));
}
//delete system
#DeleteMapping("systems/{id}")
public Map<String, Boolean> deleteSystem(#PathVariable(value = "id") Long systemId) throws ResourceNotFoundException {
System system = systemRepository.findById(systemId)
.orElseThrow(() -> new ResourceNotFoundException("System not found - ID: " + systemId));
this.systemRepository.delete(system);
Map<String, Boolean> response = new HashMap<>();
response.put("deleted", Boolean.TRUE);
return response;
}
}
Repository:
package com.blank.systemshare.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.blank.systemshare.model.System;
#Repository
public interface SystemRepository extends JpaRepository<System, Long>{
public List<System> findAllByOrderByVersionDesc();
}
App.js
var systemShareApp = angular.module('systemShareApp', [])
.controller('mainController', ($scope, $http, $window) => {
$scope.version = '1.0';
$scope.systemData = {};
$scope.createSystemFormData = {};
$scope.editSystemFormData = {};
$scope.dbErrorStatus = false;
// Get all systems
var getAllSystems = function() {
$http.get('/systemshare/api/v1/systems')
.success((data) => {
$scope.systemData = data;
$scope.dbErrorStatus = false;
console.log(data);
})
.error((error) => {
console.log('Error: ' + error);
$scope.dbErrorStatus = true;
});
};
//initial load of page - get systems.
getAllSystems();
// Create a new system
$scope.createSystem = () => {
$http.post('/systemshare/api/v1/systems', $scope.createSystemFormData)
.success((data) => {
$scope.createSystemFormData = {};
getAllSystems();
})
.error((error) => {
console.log('Error: ' + error);
});
};
// Delete a system
$scope.deleteSystem = (systemID) => {
$http.delete('/systemshare/api/v1/systems/' + systemID)
.success((data) => {
getAllSystems();
})
.error((data) => {
console.log('Error: ' + data);
});
};
// Update a system
$scope.updateSystem = (systemID) => {
$http.put('/systemshare/api/v1/systems/' + systemID, $scope.editSystemFormData)
.success((data) => {
$scope.editSystemFormData = {};
getAllSystems();
})
.error((data) => {
console.log('Error: ' + data);
});
};
//select system function for transfer of object data in list to modal.
$scope.selectSystem = function(system) {
$scope.thisSystem = system;
//editSystemFormData Modal updates:
$scope.editSystemFormData.owner = system.owner;
$scope.editSystemFormData.version = system.version;
$scope.editSystemFormData.url = system.url;
$scope.editSystemFormData.credentials = system.credentials;
$scope.editSystemFormData.frameworks = system.frameworks;
$scope.editSystemFormData.fw_credentials = system.fw_credentials;
$scope.editSystemFormData.notes = system.notes;
};
});
Application.properties
spring.datasource.url=jdbc:postgresql://xx.xx.xxx.xxx:5432/systemshare
spring.datasource.username=xx
spring.datasource.password=xx
spring.jpa.show-sql=true
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
server.servlet.contextPath=/systemshare
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.blank</groupId>
<artifactId>systemshare</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>systemshare</name>
<description>System Share Project</description>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
mvnw.cmd spring-boot:run output (working scenario)
mvnw.cmd spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.blank:systemshare >------------------------
[INFO] Building systemshare 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) > test-compile # systemshare >>>
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # systemshare ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # systemshare ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Users\user\Documents\JavaProjects\systemshare\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # systemshare ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\JavaProjects\systemshare\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # systemshare ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\user\Documents\JavaProjects\systemshare\target\test-classes
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) < test-compile # systemshare <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) # systemshare ---
[INFO] Attaching agents: []
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-21 14:50:58.430 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : Starting SystemshareApplication on L37853WUS with PID 19748 (C:\Users\user\Documents\JavaProjects\systemshare\target\classes started by userin C:\Users\mck
eb2\Documents\JavaProjects\systemshare)
2020-04-21 14:50:58.435 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : No active profile set, falling back to default profiles: default
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\user\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files th
at do not exist: file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfi
sh/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/U
sers/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-04-21 14:50:59.303 INFO 19748 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-21 14:50:59.383 INFO 19748 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 71ms. Found 1 JPA repository interfaces.
2020-04-21 14:51:00.475 INFO 19748 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-04-21 14:51:00.489 INFO 19748 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-21 14:51:00.490 INFO 19748 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-04-21 14:51:00.674 INFO 19748 --- [ restartedMain] o.a.c.c.C.[.[localhost].[/systemshare] : Initializing Spring embedded WebApplicationContext
2020-04-21 14:51:00.675 INFO 19748 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2161 ms
2020-04-21 14:51:00.858 INFO 19748 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-21 14:51:00.942 INFO 19748 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-21 14:51:01.117 INFO 19748 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-21 14:51:01.228 INFO 19748 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-21 14:51:01.603 INFO 19748 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-04-21 14:51:01.621 INFO 19748 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-04-21 14:51:02.803 INFO 19748 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-21 14:51:02.810 INFO 19748 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-21 14:51:02.825 INFO 19748 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-04-21 14:51:03.186 WARN 19748 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view
to disable this warning
2020-04-21 14:51:03.334 INFO 19748 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-21 14:51:03.402 INFO 19748 --- [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2020-04-21 14:51:03.571 INFO 19748 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/systemshare'
2020-04-21 14:51:03.575 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : Started SystemshareApplication in 5.624 seconds (JVM running for 6.47)
2020-04-21 14:51:17.737 INFO 19748 --- [nio-8080-exec-1] o.a.c.c.C.[.[localhost].[/systemshare] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-04-21 14:51:17.737 INFO 19748 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-04-21 14:51:17.745 INFO 19748 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 7 ms
WAR deployed on tomcat (non-working scenario)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-21 14:55:49.434 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on L37853WUS with PID 12280 (C:\Users\user\Documents\Software\apache-tomcat-8.5.29\webapps\systemshare\WEB-INF\classes started by user in C:\Users\user\Documents\Software\apache-tomcat-8.5.29\bin)
2020-04-21 14:55:49.451 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : No active profile set, falling back to default profiles: default
2020-04-21 14:55:52.213 INFO 12280 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-21 14:55:52.458 INFO 12280 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 200ms. Found 1 JPA repository interfaces.
2020-04-21 14:55:53.923 INFO 12280 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4212 ms
2020-04-21 14:55:55.125 INFO 12280 --- [ost-startStop-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-21 14:55:55.675 INFO 12280 --- [ost-startStop-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-21 14:55:56.461 INFO 12280 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-21 14:55:57.051 INFO 12280 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-21 14:55:57.633 INFO 12280 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-04-21 14:55:57.728 INFO 12280 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-04-21 14:56:01.538 INFO 12280 --- [ost-startStop-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-21 14:56:01.578 INFO 12280 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-21 14:56:03.216 WARN 12280 --- [ost-startStop-1] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-21 14:56:03.699 INFO 12280 --- [ost-startStop-1] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-21 14:56:04.075 INFO 12280 --- [ost-startStop-1] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2020-04-21 14:56:04.472 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : Started ServletInitializer in 16.741 seconds (JVM running for 32.139)
21-Apr-2020 14:56:04.517 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [C:\Users\user\Documents\Software\apache-tomcat-8.5.29\webapps\systemshare.war] has finished in [25,067] ms
Specific 404 error message from Chrome devtools:
{
"timestamp":"2020-04-21T19:50:27.749+0000",
"status":404,
"error":"Not Found",
"message":"No message available",
"path":"/systemshare/api/v1/systems"
}
Also, tomcat logs don't show anything useful.

Removing the ServletInitializer.java class and updating my application file to the following resolved the issue (extending SpringBootServletInitializer and overriding the configure method). Note that I tried this before, but built the application using both Eclipse and InteliJ. Both times the same issue still occurred. This final time I built using mvnw package and the WAR generated in the target directory worked.
package com.blank.systemshare;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
#SpringBootApplication
public class SystemshareApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SystemshareApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SystemshareApplication.class);
}
}

Try server.servlet.context-path instead of server.servlet.contextPath.

Related

Not saving to database, Spring Boot, Hibernate, PostgreSQL

Spring Boot 3.0.0 application, after filling out the form and submitting it, the input field is cleared, but saving to the corresponding database table does not occur. There are no errors in the log.
Model
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
#Entity
public class Message {
#Id
#GeneratedValue(strategy= GenerationType.AUTO)
private Integer id;
private String text;
public Message() {
}
public Message(String text) {
this.text = text;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
Repository
import kz.onlineshelter.helppet.model.Message;
import org.springframework.data.repository.CrudRepository;
public interface MessageRepository extends CrudRepository<Message, Long> {}
Controller
import kz.onlineshelter.helppet.model.Message;
import kz.onlineshelter.helppet.repository.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
#Controller
#RequestMapping(method={RequestMethod.POST,RequestMethod.GET})
public class AppController {
private final MessageRepository messageRepository;
#Autowired
public AppController(MessageRepository messageRepository) {
this.messageRepository = messageRepository;
}
#GetMapping("/message")
public String message(Map<String, Object> model) {
Iterable<Message> messages = messageRepository.findAll();
model.put("messages", messages);
return "message";
}
#PostMapping
public String add(#RequestParam String text, Map<String, Object> model) {
Message message = new Message(text);
messageRepository.save(message);
Iterable<Message> messages = messageRepository.findAll();
model.put("messages", messages);
return "message";
}
}
Application
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelppetApplication {
public static void main(String[] args) {
SpringApplication.run(HelppetApplication.class, args);
}
}
resources/templates/message.mustache
<html>
<body>
<div>
<form method="post">
<input type="text" name="text" placeholder="Enter your text" /><br>
<button type="submit">Add</button>
</form>
</div>
<div>List of messages</div>
{{#messages}}
<div>
<span>{{text}}</span>
</div>
{{/messages}}
</body>
</html>
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/***
spring.datasource.username=***
spring.datasource.password=***
spring.jpa.generate-ddl=true
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>***</groupId>
<artifactId>helppet</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>***</name>
<description>***</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mustache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</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>
log file
"C:\Program Files\BellSoft\LibericaJDK-17\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=63010:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\bin" -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "C:\java projects\helppet\target\classes;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\3.0.0\spring-boot-starter-data-jpa-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-aop\3.0.0\spring-boot-starter-aop-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-aop\6.0.2\spring-aop-6.0.2.jar;C:\Users\Admin\.m2\repository\org\aspectj\aspectjweaver\1.9.9.1\aspectjweaver-1.9.9.1.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\3.0.0\spring-boot-starter-jdbc-3.0.0.jar;C:\Users\Admin\.m2\repository\com\zaxxer\HikariCP\5.0.1\HikariCP-5.0.1.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-jdbc\6.0.2\spring-jdbc-6.0.2.jar;C:\Users\Admin\.m2\repository\org\hibernate\orm\hibernate-core\6.1.5.Final\hibernate-core-6.1.5.Final.jar;C:\Users\Admin\.m2\repository\jakarta\persistence\jakarta.persistence-api\3.1.0\jakarta.persistence-api-3.1.0.jar;C:\Users\Admin\.m2\repository\jakarta\transaction\jakarta.transaction-api\2.0.1\jakarta.transaction-api-2.0.1.jar;C:\Users\Admin\.m2\repository\org\jboss\logging\jboss-logging\3.5.0.Final\jboss-logging-3.5.0.Final.jar;C:\Users\Admin\.m2\repository\org\hibernate\common\hibernate-commons-annotations\6.0.2.Final\hibernate-commons-annotations-6.0.2.Final.jar;C:\Users\Admin\.m2\repository\org\jboss\jandex\2.4.2.Final\jandex-2.4.2.Final.jar;C:\Users\Admin\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\Admin\.m2\repository\net\bytebuddy\byte-buddy\1.12.19\byte-buddy-1.12.19.jar;C:\Users\Admin\.m2\repository\org\glassfish\jaxb\jaxb-runtime\4.0.1\jaxb-runtime-4.0.1.jar;C:\Users\Admin\.m2\repository\org\glassfish\jaxb\jaxb-core\4.0.1\jaxb-core-4.0.1.jar;C:\Users\Admin\.m2\repository\org\eclipse\angus\angus-activation\1.0.0\angus-activation-1.0.0.jar;C:\Users\Admin\.m2\repository\org\glassfish\jaxb\txw2\4.0.1\txw2-4.0.1.jar;C:\Users\Admin\.m2\repository\com\sun\istack\istack-commons-runtime\4.1.1\istack-commons-runtime-4.1.1.jar;C:\Users\Admin\.m2\repository\jakarta\inject\jakarta.inject-api\2.0.0\jakarta.inject-api-2.0.0.jar;C:\Users\Admin\.m2\repository\org\antlr\antlr4-runtime\4.10.1\antlr4-runtime-4.10.1.jar;C:\Users\Admin\.m2\repository\org\springframework\data\spring-data-jpa\3.0.0\spring-data-jpa-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\data\spring-data-commons\3.0.0\spring-data-commons-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-orm\6.0.2\spring-orm-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-context\6.0.2\spring-context-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-tx\6.0.2\spring-tx-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-beans\6.0.2\spring-beans-6.0.2.jar;C:\Users\Admin\.m2\repository\org\slf4j\slf4j-api\2.0.4\slf4j-api-2.0.4.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-aspects\6.0.2\spring-aspects-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-mustache\3.0.0\spring-boot-starter-mustache-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter\3.0.0\spring-boot-starter-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.0.0\spring-boot-starter-logging-3.0.0.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-classic\1.4.5\logback-classic-1.4.5.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-core\1.4.5\logback-core-1.4.5.jar;C:\Users\Admin\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.19.0\log4j-to-slf4j-2.19.0.jar;C:\Users\Admin\.m2\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;C:\Users\Admin\.m2\repository\org\slf4j\jul-to-slf4j\2.0.4\jul-to-slf4j-2.0.4.jar;C:\Users\Admin\.m2\repository\org\yaml\snakeyaml\1.33\snakeyaml-1.33.jar;C:\Users\Admin\.m2\repository\com\samskivert\jmustache\1.15\jmustache-1.15.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.0.0\spring-boot-starter-web-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.0.0\spring-boot-starter-json-3.0.0.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.14.1\jackson-databind-2.14.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.14.1\jackson-annotations-2.14.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.14.1\jackson-core-2.14.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.14.1\jackson-datatype-jdk8-2.14.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.14.1\jackson-datatype-jsr310-2.14.1.jar;C:\Users\Admin\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.14.1\jackson-module-parameter-names-2.14.1.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-web\6.0.2\spring-web-6.0.2.jar;C:\Users\Admin\.m2\repository\io\micrometer\micrometer-observation\1.10.2\micrometer-observation-1.10.2.jar;C:\Users\Admin\.m2\repository\io\micrometer\micrometer-commons\1.10.2\micrometer-commons-1.10.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-webmvc\6.0.2\spring-webmvc-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-expression\6.0.2\spring-expression-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-devtools\3.0.0\spring-boot-devtools-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot\3.0.0\spring-boot-3.0.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.0.0\spring-boot-autoconfigure-3.0.0.jar;C:\Users\Admin\.m2\repository\org\postgresql\postgresql\42.5.1\postgresql-42.5.1.jar;C:\Users\Admin\.m2\repository\org\checkerframework\checker-qual\3.5.0\checker-qual-3.5.0.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.0.0\spring-boot-starter-tomcat-3.0.0.jar;C:\Users\Admin\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\Admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.1\tomcat-embed-core-10.1.1.jar;C:\Users\Admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.1\tomcat-embed-el-10.1.1.jar;C:\Users\Admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.1\tomcat-embed-websocket-10.1.1.jar;C:\Users\Admin\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\4.0.0\jakarta.xml.bind-api-4.0.0.jar;C:\Users\Admin\.m2\repository\jakarta\activation\jakarta.activation-api\2.1.0\jakarta.activation-api-2.1.0.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-core\6.0.2\spring-core-6.0.2.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-jcl\6.0.2\spring-jcl-6.0.2.jar" kz.onlineshelter.helppet.HelppetApplication
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0)
2022-12-22T10:18:07.901+03:00 INFO 8316 --- [ restartedMain] k.o.***.***Application : Starting ***Application using Java 17.0.4.1 with PID 8316 (*:\***\***\target\classes started by Admin in *:\***\***)
2022-12-22T10:18:07.903+03:00 INFO 8316 --- [ restartedMain] k.o.***.***Application : No active profile set, falling back to 1 default profile: "default"
2022-12-22T10:18:07.944+03:00 INFO 8316 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-12-22T10:18:07.944+03:00 INFO 8316 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-12-22T10:18:08.400+03:00 INFO 8316 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-12-22T10:18:08.435+03:00 INFO 8316 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 30 ms. Found 1 JPA repository interfaces.
2022-12-22T10:18:08.807+03:00 INFO 8316 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-12-22T10:18:08.815+03:00 INFO 8316 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-12-22T10:18:08.815+03:00 INFO 8316 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-22T10:18:08.861+03:00 INFO 8316 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-12-22T10:18:08.861+03:00 INFO 8316 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 917 ms
2022-12-22T10:18:08.950+03:00 INFO 8316 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-12-22T10:18:09.038+03:00 INFO 8316 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection#54ef2cef
2022-12-22T10:18:09.039+03:00 INFO 8316 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-12-22T10:18:09.070+03:00 INFO 8316 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-12-22T10:18:09.110+03:00 INFO 8316 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-12-22T10:18:09.232+03:00 WARN 8316 --- [ restartedMain] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-12-22T10:18:09.344+03:00 INFO 8316 --- [ restartedMain] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-12-22T10:18:09.824+03:00 INFO 8316 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-12-22T10:18:09.830+03:00 INFO 8316 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-12-22T10:18:10.004+03:00 WARN 8316 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2022-12-22T10:18:10.234+03:00 INFO 8316 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-12-22T10:18:10.256+03:00 INFO 8316 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-22T10:18:10.265+03:00 INFO 8316 --- [ restartedMain] k.o.helppet.HelppetApplication : Started HelppetApplication in 2.768 seconds (process running for 4.113)
2022-12-22T10:18:13.951+03:00 INFO 8316 --- [nio-8080-exec-5] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-12-22T10:18:13.952+03:00 INFO 8316 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-12-22T10:18:13.954+03:00 INFO 8316 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
After starting the application, the corresponding table in the database is successfully created
I added an annotation #Repository into Repository, added an annotation #Transactional into Controller in add method, into the signature of the same method added an anotation #ResponseBody but that didn't solve the issue.

I'm making a simple aop example and it does not work

I'm new to java and Spring and I'm currently trying to understand aop. I'm trying to implement very simple code with my custom annotation and #After advice and for some reason it does not work, what I expected was to get on the console 1 and the 2 insted I get only 1 do any of you guys know why?
annotation
package Terative.Services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
#Retention(RetentionPolicy.RUNTIME)
#Target(ElementType.METHOD)
public #interface MyAnnotation {
}
pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</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>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
psvm
package Terative;
import Terative.Services.Simulation_service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
#EnableAspectJAutoProxy
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
Simulation_service mm = new Simulation_service();
mm.metoda();
}
}
aspect
package Terative.Services;
import lombok.RequiredArgsConstructor;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
#RequiredArgsConstructor
#org.springframework.stereotype.Service
#Aspect
#Component
public class Simulation_service {
#Pointcut("#annotation(MyAnnotation)")
public void MyAnnotationMethod() {
}
#MyAnnotation
public void metoda() {
System.out.println("1");
}
#After("MyAnnotationMethod()")
public void metoda2() {
System.out.println("2");
}
}
C:\Users\mtsge\.jdks\azul-13.0.6\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\lib\idea_rt.jar=51747:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\mtsge\OneDrive\Pulpit\j\demo\target\classes;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.5.2\spring-boot-starter-aop-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter\2.5.2\spring-boot-starter-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot\2.5.2\spring-boot-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.5.2\spring-boot-autoconfigure-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.5.2\spring-boot-starter-logging-2.5.2.jar;C:\Users\mtsge\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\mtsge\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\mtsge\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.14.1\log4j-to-slf4j-2.14.1.jar;C:\Users\mtsge\.m2\repository\org\apache\logging\log4j\log4j-api\2.14.1\log4j-api-2.14.1.jar;C:\Users\mtsge\.m2\repository\org\slf4j\jul-to-slf4j\1.7.31\jul-to-slf4j-1.7.31.jar;C:\Users\mtsge\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\mtsge\.m2\repository\org\yaml\snakeyaml\1.28\snakeyaml-1.28.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-aop\5.3.8\spring-aop-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-beans\5.3.8\spring-beans-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\aspectj\aspectjweaver\1.9.6\aspectjweaver-1.9.6.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.5.2\spring-boot-starter-data-jpa-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.5.2\spring-boot-starter-jdbc-2.5.2.jar;C:\Users\mtsge\.m2\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-jdbc\5.3.8\spring-jdbc-5.3.8.jar;C:\Users\mtsge\.m2\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\Users\mtsge\.m2\repository\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\Users\mtsge\.m2\repository\org\hibernate\hibernate-core\5.4.32.Final\hibernate-core-5.4.32.Final.jar;C:\Users\mtsge\.m2\repository\org\jboss\logging\jboss-logging\3.4.2.Final\jboss-logging-3.4.2.Final.jar;C:\Users\mtsge\.m2\repository\org\javassist\javassist\3.27.0-GA\javassist-3.27.0-GA.jar;C:\Users\mtsge\.m2\repository\net\bytebuddy\byte-buddy\1.10.22\byte-buddy-1.10.22.jar;C:\Users\mtsge\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\mtsge\.m2\repository\org\jboss\jandex\2.2.3.Final\jandex-2.2.3.Final.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\mtsge\.m2\repository\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;C:\Users\mtsge\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.1.2.Final\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\mtsge\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.4\jaxb-runtime-2.3.4.jar;C:\Users\mtsge\.m2\repository\org\glassfish\jaxb\txw2\2.3.4\txw2-2.3.4.jar;C:\Users\mtsge\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.12\istack-commons-runtime-3.0.12.jar;C:\Users\mtsge\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\data\spring-data-jpa\2.5.2\spring-data-jpa-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\data\spring-data-commons\2.5.2\spring-data-commons-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-orm\5.3.8\spring-orm-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-context\5.3.8\spring-context-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-tx\5.3.8\spring-tx-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\slf4j\slf4j-api\1.7.31\slf4j-api-1.7.31.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-aspects\5.3.8\spring-aspects-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.5.2\spring-boot-starter-web-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.5.2\spring-boot-starter-json-2.5.2.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.12.3\jackson-databind-2.12.3.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.12.3\jackson-annotations-2.12.3.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.12.3\jackson-core-2.12.3.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.12.3\jackson-datatype-jdk8-2.12.3.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.12.3\jackson-datatype-jsr310-2.12.3.jar;C:\Users\mtsge\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.12.3\jackson-module-parameter-names-2.12.3.jar;C:\Users\mtsge\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.5.2\spring-boot-starter-tomcat-2.5.2.jar;C:\Users\mtsge\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.48\tomcat-embed-core-9.0.48.jar;C:\Users\mtsge\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.48\tomcat-embed-el-9.0.48.jar;C:\Users\mtsge\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.48\tomcat-embed-websocket-9.0.48.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-web\5.3.8\spring-web-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-webmvc\5.3.8\spring-webmvc-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-expression\5.3.8\spring-expression-5.3.8.jar;C:\Users\mtsge\.m2\repository\mysql\mysql-connector-java\8.0.25\mysql-connector-java-8.0.25.jar;C:\Users\mtsge\.m2\repository\org\projectlombok\lombok\1.18.20\lombok-1.18.20.jar;C:\Users\mtsge\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\Users\mtsge\.m2\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-core\5.3.8\spring-core-5.3.8.jar;C:\Users\mtsge\.m2\repository\org\springframework\spring-jcl\5.3.8\spring-jcl-5.3.8.jar Terative.DemoApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.2)
2021-06-26 16:15:03.432 INFO 8188 --- [ main] Terative.DemoApplication : Starting DemoApplication using Java 13.0.6 on DESKTOP-61G00PJ with PID 8188 (C:\Users\mtsge\OneDrive\Pulpit\j\demo\target\classes started by mtsge in C:\Users\mtsge\OneDrive\Pulpit\j\demo)
2021-06-26 16:15:03.432 INFO 8188 --- [ main] Terative.DemoApplication : No active profile set, falling back to default profiles: default
2021-06-26 16:15:05.764 INFO 8188 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-26 16:15:05.800 INFO 8188 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11 ms. Found 0 JPA repository interfaces.
2021-06-26 16:15:07.758 INFO 8188 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-06-26 16:15:07.779 INFO 8188 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-26 16:15:07.779 INFO 8188 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.48]
2021-06-26 16:15:08.007 INFO 8188 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-26 16:15:08.007 INFO 8188 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4292 ms
2021-06-26 16:15:08.462 INFO 8188 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-06-26 16:15:08.555 INFO 8188 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-06-26 16:15:08.801 INFO 8188 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-06-26 16:15:08.961 INFO 8188 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-26 16:15:09.603 INFO 8188 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-06-26 16:15:09.681 INFO 8188 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2021-06-26 16:15:10.478 INFO 8188 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-06-26 16:15:10.499 INFO 8188 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-06-26 16:15:10.612 WARN 8188 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-06-26 16:15:11.930 INFO 8188 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-06-26 16:15:11.945 INFO 8188 --- [ main] Terative.DemoApplication : Started DemoApplication in 9.53 seconds (JVM running for 10.837)
1
Process finished with exit code -1
Here you create the instance by your self. Spring can not use any aspect on that as it does not belong to the spring context.
Simulation_service mm = new Simulation_service();
mm.metoda();
You need to retrieve the instance from the spring context. Then invoking the method will cause the aspect to execute.
public static void main(String[] args) {
ApplicationContext context = SpringApplication.run(DemoApplication.class, args);
Simulation_service mm = context.getBean(Simulation_service.class)
mm.metoda();
}
If everything else is fine tuned it will work. In every case what I describe here is a must in order to move forward.
Turns out advice and custom annotation can't be in the same class which is understandable given the reason for which aop was created, I moved method with custom annotation metoda() to another class and marked it ith #Bean annotation

Spring application stuck in start

I have a problem since I export and import a spring project, and it is that now it takes more than 70 seconds to start. Get stuck in Triggering deferred initialization of Spring Data repositories ...
This is the log of the console:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2021-01-19 21:00:48.994 INFO 15368 --- [ restartedMain] com.practica.PracticaFinalApplication : Starting PracticaFinalApplication on DESKTOP-BG6SBT4 with PID 15368 (D:\workspace-spring-tool-suite-4-4.8.0.RELEASE\PRACTICA_FINAL\target\classes started by dani_ in D:\workspace-spring-tool-suite-4-4.8.0.RELEASE\PRACTICA_FINAL)
2021-01-19 21:00:48.998 INFO 15368 --- [ restartedMain] com.practica.PracticaFinalApplication : No active profile set, falling back to default profiles: default
2021-01-19 21:00:49.051 INFO 15368 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\dani_\.m2\repository\com\oracle\database\jdbc\ojdbc8\19.3.0.0\ojdbc8-19.3.0.0.jar referenced one or more files that do not exist: file:/C:/Users/dani_/.m2/repository/com/oracle/database/jdbc/ojdbc8/19.3.0.0/oraclepki.jar
2021-01-19 21:00:49.051 INFO 15368 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\dani_\.m2\repository\com\oracle\database\security\oraclepki\19.3.0.0\oraclepki-19.3.0.0.jar referenced one or more files that do not exist: file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/19.3.0.0/osdt_core.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/19.3.0.0/osdt_cert.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/oracle.osdt/osdt_core.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/oracle.osdt/osdt_cert.jar
2021-01-19 21:00:49.052 INFO 15368 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-01-19 21:00:49.052 INFO 15368 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-01-19 21:00:49.767 INFO 15368 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2021-01-19 21:00:49.848 INFO 15368 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 75ms. Found 6 JPA repository interfaces.
2021-01-19 21:00:50.143 INFO 15368 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$5974c00c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-19 21:00:50.203 INFO 15368 --- [ restartedMain] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2021-01-19 21:00:50.575 INFO 15368 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2021-01-19 21:00:50.586 INFO 15368 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-19 21:00:50.587 INFO 15368 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2021-01-19 21:00:50.709 INFO 15368 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-19 21:00:50.710 INFO 15368 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1658 ms
2021-01-19 21:00:50.967 INFO 15368 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-19 21:00:51.007 INFO 15368 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-19 21:00:51.055 INFO 15368 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2021-01-19 21:00:51.101 WARN 15368 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-01-19 21:00:51.160 INFO 15368 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2021-01-19 21:00:51.267 INFO 15368 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-01-19 21:00:51.313 INFO 15368 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#5548d944, org.springframework.security.web.context.SecurityContextPersistenceFilter#52db2e9a, org.springframework.security.web.header.HeaderWriterFilter#2682a673, org.springframework.security.web.csrf.CsrfFilter#384244c7, org.springframework.security.web.authentication.logout.LogoutFilter#60a9bf00, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#14f3c976, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#14a70864, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#9aabdd5, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#61618c62, org.springframework.security.web.session.SessionManagementFilter#1e6efa12, org.springframework.security.web.access.ExceptionTranslationFilter#72c01891, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#43f59fcf]
2021-01-19 21:00:51.534 INFO 15368 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-01-19 21:00:51.551 INFO 15368 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
2021-01-19 21:00:51.756 INFO 15368 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-01-19 21:00:51.825 INFO 15368 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8085 (http) with context path ''
2021-01-19 21:00:51.828 INFO 15368 --- [ restartedMain] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2021-01-19 21:02:03.729 WARN 15368 --- [ task-1] o.h.b.i.InFlightMetadataCollectorImpl : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:03.741 WARN 15368 --- [ task-1] o.h.b.i.InFlightMetadataCollectorImpl : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:03.744 WARN 15368 --- [ task-1] o.h.b.i.InFlightMetadataCollectorImpl : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:04.203 INFO 15368 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-01-19 21:02:04.211 INFO 15368 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-01-19 21:02:04.639 INFO 15368 --- [ restartedMain] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2021-01-19 21:02:04.647 INFO 15368 --- [ restartedMain] com.practica.PracticaFinalApplication : Started PracticaFinalApplication in 76.038 seconds (JVM running for 77.006)
And this is the pom.xml
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.3.4.RELEASE
com.practica
PRACTICA_FINAL
0.0.1-SNAPSHOT
war
PRACTICA_FINAL
Practica
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>1.3.24</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In case it works for someone, I found the solution. I just had to add these two lines in my properties file and I went from starting in 70 seconds to starting in 4 seconds
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.properties.hibernate.dialect =org.hibernate.dialect.Oracle12cDialect

I got whitelabel error page instead of eureka dashboard

I'm following a tutorial about Eureka to start up a sample eureka server ,I followed exactly the same steps but i get a whitelabel insteed of eureka dashbord, I will share with you all the configuration that I made
the POM.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com..discovery.service</groupId>
<artifactId>descoveryservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>descoveryservice</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
application.properties :
server.port=8010
spring.application.name=discoveryservice
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone = http://localhost:8010/eureka
and the finally the console :
2020-05-07 16:15:59.358 INFO 21060 --- [ main] o.s.core.annotation.AnnotationUtils : Failed to introspect annotations on class org.springframework.cloud.netflix.eureka.config.EurekaDiscoveryClientConfigServiceBootstrapConfiguration: java.lang.IllegalStateException: Could not obtain annotation attribute value for public abstract java.lang.Class[] org.springframework.boot.autoconfigure.condition.ConditionalOnClass.value()
2020-05-07 16:15:59.679 INFO 21060 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$97f8ff4f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2020-05-07 16:16:01.722 INFO 21060 --- [ main] c.d.s.d.DescoveryserviceApplication : No active profile set, falling back to default profiles: default
2020-05-07 16:16:02.829 WARN 21060 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2020-05-07 16:16:03.242 INFO 21060 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=889ab658-056e-3973-ba9c-f9fdd0f82c43
2020-05-07 16:16:03.378 INFO 21060 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$97f8ff4f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-07 16:16:04.447 INFO 21060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8010 (http)
2020-05-07 16:16:04.491 INFO 21060 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-07 16:16:04.491 INFO 21060 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2020-05-07 16:16:04.509 INFO 21060 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk-11.0.6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk-11.0.6/bin/server;C:/Program Files/Java/jdk-11.0.6/bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\novatim\AppData\Local\Microsoft\WindowsApps;C:\Users\novatim\Desktop\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;C:\Program Files\Java\jdk-11.0.6\bin;;C:\Users\novatim\Desktop\eclipse-jee-2019-12-R-win32-x86_64\eclipse;;.]
2020-05-07 16:16:04.768 INFO 21060 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-07 16:16:04.768 INFO 21060 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2996 ms
2020-05-07 16:16:04.935 WARN 21060 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-05-07 16:16:04.936 INFO 21060 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-07 16:16:04.962 INFO 21060 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#13ed066e
2020-05-07 16:16:06.652 INFO 21060 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2020-05-07 16:16:08.337 INFO 21060 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2020-05-07 16:16:08.963 WARN 21060 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-05-07 16:16:08.964 INFO 21060 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-07 16:16:09.222 INFO 21060 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-07 16:16:10.021 INFO 21060 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-05-07 16:16:10.174 INFO 21060 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2020-05-07 16:16:10.226 INFO 21060 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2020-05-07 16:16:10.229 INFO 21060 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2020-05-07 16:16:10.243 INFO 21060 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1588860970242 with initial instances count: 0
2020-05-07 16:16:10.250 INFO 21060 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application discoveryservice with eureka with status UP
2020-05-07 16:16:10.326 INFO 21060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8010 (http) with context path ''
2020-05-07 16:16:10.333 INFO 21060 --- [ main] c.d.s.d.DescoveryserviceApplication : Started DescoveryserviceApplication in 13.391 seconds (JVM running for 14.094)
2020-05-07 16:16:17.202 INFO 21060 --- [nio-8010-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-07 16:16:17.204 INFO 21060 --- [nio-8010-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-07 16:16:17.223 INFO 21060 --- [nio-8010-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 19 ms
I do not know where the problem is it has been several hours that I am looking for a solution, if you have ideas do not hesitate to share them,
Thanks .
I guess you didn't add #EnableEurekaServer annotation to your main app
It should be like this
#SpringBootApplication
#EnableEurekaServer
public class DiscoveryServerApplication {
…
}

Basic Controller Configuration Not working in Spring Boot

I am creating a sample project using Spring Boot and tried to map / with a simple String message. I have used #Controller annotation for this purpose. But for some reason the mapping is not working. I have also included #ComponentScan and #EnableWebMvc with no luck.
I have used maven spring-boot:run goal to run. Uploaded the project at https://github.com/tejact/SpringBasicsTreeHouse.
Here is the controller:
package Controller;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Component
#Controller
public class GifController {
#RequestMapping("/")
#ResponseBody
public String listAllGifs() {
return "Listing all gifs : Madhu";
}
}
The main application entry:
package com.teja;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
#EnableAutoConfiguration
#ComponentScan
#EnableWebMvc
public class AppConfig {
public static void main(String args[]) {
SpringApplication.run(AppConfig.class, args);
}
}
And Spring Boot logs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpingBasicsTreeHouse 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) > test-compile # SpingBasicsTreeHouse >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SpingBasicsTreeHouse ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # SpingBasicsTreeHouse ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 2 source files to C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SpingBasicsTreeHouse ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # SpingBasicsTreeHouse ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) < test-compile # SpingBasicsTreeHouse <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) # SpingBasicsTreeHouse ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2016-07-31 13:18:24.593 INFO 11084 --- [ main] com.teja.AppConfig : Starting AppConfig on Teja-PC with PID 11084 (C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse\target\classes started by Teja in C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse)
2016-07-31 13:18:24.598 INFO 11084 --- [ main] com.teja.AppConfig : No active profile set, falling back to default profiles: default
2016-07-31 13:18:24.712 INFO 11084 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ae4a4a3: startup date [Sun Jul 31 13:18:24 EDT 2016]; root of context hierarchy
2016-07-31 13:18:26.868 INFO 11084 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-07-31 13:18:26.885 INFO 11084 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-07-31 13:18:26.886 INFO 11084 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2016-07-31 13:18:27.002 INFO 11084 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-07-31 13:18:27.003 INFO 11084 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2297 ms
2016-07-31 13:18:27.184 INFO 11084 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-07-31 13:18:27.191 INFO 11084 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-07-31 13:18:27.434 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ae4a4a3: startup date [Sun Jul 31 13:18:24 EDT 2016]; root of context hierarchy
2016-07-31 13:18:27.582 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-07-31 13:18:27.587 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-07-31 13:18:28.004 INFO 11084 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-07-31 13:18:28.082 INFO 11084 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-07-31 13:18:28.087 INFO 11084 --- [ main] com.teja.AppConfig : Started AppConfig in 4.278 seconds (JVM running for 12.677)
Also my pom.xml looks like the following:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TreeHouse</groupId>
<artifactId>SpingBasicsTreeHouse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
By default #ComponentScan scans the the current package and all the sub packages.
In your case AppConfig class is in package com.teja and the GifController is in Controller package, so it's not scanned.
Move GifController to com.teja.controller for example, or any other sub package of com.teja and it will work.
Usually I keep the bootstraping class and all the configuration classes in package named <com|org|etc>.<myCompany>.<myProject> and then create the other packages as sub packages of this one.
Also you don't need both #Component and #Controller. Remove #Component -#Controller already inherits #Component.

Categories

Resources