Spring Boot (version 3.0.2) - Validation not working - spring-boot

I am using #NotBlank and #Size in the command object.
Partial code below:
enter mport javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
public class WatchlistItem {
#NotBlank(message="You cannot leave it empty")
private String title;
private String rating;
#NotBlank(message = "cannot leave blank")
private String priority;
#Size(max = 50, message = "The maximum characters are 50")
private String comment;
Part of the controller class:
#PostMapping("/watchlistItemForm")
public ModelAndView submitWatchlistItemForm(#Valid WatchlistItem watchlistItem,
BindingResult bindingResult ){
if (bindingResult.hasErrors()){
return new ModelAndView ("watchlistItemForm");
}
WatchlistItem updateItem = getWatchListItemById(watchlistItem.getId());
And the pom file:
<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.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.openclassrooms</groupId>
<artifactId>watchlist23</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>watchlist23</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</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-thymeleaf</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-devtools</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
But when I run the application, I can leave the title field blank and still works, whereas it should stop and ask me to enter the title.
Please advice.

Related

Spring Data JPA intelligence not working in Intellij for OneToMany relation

I have setup new spring boot project with Spring Data JPA and would like to use auto-completion feature to find all records by nested property.
intellij hint for repository method is missing nested properties
I want to retrieve Customers that have matching zipCodes. Declared entities:
#Entity
#Getter
public class Customer {
#Id
private long id;
private String firstName;
#OneToMany(targetEntity = Address.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Address> addresses;
}
#Entity
#Getter
public class Address {
#Id
private long id;
private String streetName;
private String zipCode;
}
It should work out of the box like in article here: https://evonsdesigns.medium.com/spring-jpa-one-to-many-query-examples-281078bc457b
but it does not work. I tried it with following pom config:
<?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.7</version>
<relativePath/>
</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Tried on IntelliJ IDEA 2021.3 (Ultimate Edition)

Error while creating dynamic cloud config using actuator

The controller is InfyGo_Booking to which #RefreshScope is added and also added required dependencies in pom.xml. I have also exposed the endpoints in bootstrap.properties. But still https://localhost:9000/actuator/refresh is giving me 404 error. Can you help me pointing out if I am missing something?
Controller:
#RestController
#RefreshScope
#RequestMapping("/book")
public class BookingController {
protected Logger logger = Logger.getLogger(BookingController.class.getName());
#Autowired
private TicketService ticketService;
#Autowired
private PassengerService passengerService;
private Ticket ticket;
private int noOfSeats;
ClientHttpRequestFactory requestFactory = new
HttpComponentsClientHttpRequestFactory(HttpClients.createDefault());
RestTemplate restTemplate = new RestTemplate(requestFactory);
//
public BookingController() {
ticket = new Ticket();
}
#PostMapping(value = "/{flightId}/{username}", produces = "application/json", consumes = "application/json")
public ResponseEntity<BookingDetails> bookFlight(#PathVariable("flightId") String flightId,
#Valid #RequestBody PassengerDetails passengerDetails, #PathVariable("username") String username,Errors errors) throws InfyGoServiceException, ARSServiceException {
if (errors.hasErrors()) {
return new ResponseEntity(new ClientErrorInformation(HttpStatus.BAD_REQUEST.value(),errors.getFieldError("passengerList").getDefaultMessage()), HttpStatus.BAD_REQUEST);
}
if(passengerDetails.getPassengerList().isEmpty())
throw new InfyGoServiceException(ExceptionConstants.PASSENGER_LIST_EMPTY.toString());
List<Passenger> passengerList = new ArrayList<Passenger>();
for (Passenger passengers : passengerDetails.getPassengerList()) {
passengerList.add(passengers);
}
System.out.println(passengerList.toString());
logger.log(Level.INFO, "Book Flight method ");
logger.log(Level.INFO, passengerDetails.toString());
int pnr = (int) (Math.random() * 1858955);
ticket.setPnr(pnr);
// Date date = new Date();
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
Flight flightDto= restTemplate.getForObject("http://localhost:9004/flights/"+flightId, Flight.class);
double fare= flightDto.getFare();
System.out.println("Fare per person:****** " + fare);
System.out.println("List size:****** " + passengerDetails.getPassengerList().size());
double totalFare = fare * (passengerDetails.getPassengerList().size());
BookingDetails bookingDetails = new BookingDetails();
bookingDetails.setPassengerList(passengerDetails.getPassengerList());
bookingDetails.setPnr(pnr);
bookingDetails.setTotalFare(totalFare);
ticket.setBookingDate(new Date());
System.out.println(ticket.getBookingDate());
ticket.setDepartureDate(flightDto.getFlightAvailableDate());
ticket.setDepartureTime(flightDto.getDepartureTime());
ticket.setFlightId(flightDto.getFlightId());
ticket.setUserId(username);
ticket.setTotalFare(totalFare);
noOfSeats = passengerDetails.getPassengerList().size();
ticket.setNoOfSeats(noOfSeats);
ticketService.createTicket(ticket);
addPassengers(bookingDetails.getPassengerList());
restTemplate.postForEntity("http://localhost:9004/flights/"+flightId+"/"+noOfSeats,null,null);
return new ResponseEntity<BookingDetails>(bookingDetails, HttpStatus.OK);
}
private void addPassengers(List<Passenger> passengers) {
for (Passenger passenger : passengers) {
passenger.setTicket(ticket);
}
passengerService.createPassenger(passengers);
}
}
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.3.1.RELEASE</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>1.8</java.version>
<spring-cloud.version>Hoxton.SR5</spring-cloud.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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</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-activemq</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</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>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
bootstrap.properties:
spring.cloud.config.uri=http://localhost:1111
management.endpoints.web.exposure.include=*
It looks like you are trying to call the actuator as a URL from browser which by default uses GET method . Please try the same URL and hit a post request using any app , you must see a success response .

EnableWebMvcConfiguration required a bean named 'entityManagerFactory' that could not be found

I'm having the error below when I attempt to create a second table in my database directly from my project:
EnableWebMvcConfiguration required a bean named 'entityManagerFactory'
that could not be found.
I've tried many different solutions on google with no success I hope you experts can help me fix this issue
Here is my Controller Class:
#Controller
public class EmployeeController {
#Autowired
private EmployeeService employeeService;
#Autowired
private UserService userService;
#GetMapping("/")
public String employees(Model model){
List<Worker> employees = employeeService.getAllWorkers();
model.addAttribute("employees", employees);
model.addAttribute("employee", new Worker());
model.addAttribute("title", "employees"); //Tab title
model.addAttribute("isAdd", true);
return "workers";
}
#PostMapping(value = "/save")
public String save(#ModelAttribute Worker worker, RedirectAttributes redirectAttributes){
Worker dbWorker = employeeService.save(worker);
return null;
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/user_worker?createDatabaseIfNotExist=true&serverTimezone=America/New_York
spring.datasource.username=admin
spring.datasource.password=root
spring.datasource.testWhileIdle=true
spring.datasource.tomcat.validation-query=Select 1
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.datasource.initialization-mode=always
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 http://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.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.madcoderz</groupId>
<artifactId>studentaccounts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>studentaccountsapp</name>
<description>Student Accounts App</description>
<properties>
<java.version>12</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>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.4.RELEASE</version>
</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>
MainClass:
#SpringBootApplication(scanBasePackages = {"com.madcoderz.studentaccountsapp.repository"})
public class StudentAccountsApp{
public static void main(String[] args) {
SpringApplication.run(StudentAccountsApp.class, args);
}
}

jackson-data-format doesn't convert when using with restTemplate getforObject()

This question is related to [Rest template getForObject() mapping only camel case fields
Having a rest web service that returns the below xml response.
<Person>
<ttId>1408</ttId>
<FirstName>RAJ</FirstName>
<NationalityValue>INDIAN</NationalityValue>
<Sex>Male</Sex>
</Person>
This is the dto
import java.io.Serializable;
import java.util.Date;
public class PersonInfoDto implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Long ttId;
private String NationalityValue;
private String Sex;
private String FirstName;
//getters and setters
}
Using Spring Boot, When I try to consume using code it returns only one value(which is in camel case). Do I need to add any Naming strategy to make it work ?
String uri = apiPath;
RestTemplate restTemplate = new RestTemplate();
PersonInfoDto personInfoDto = restTemplate.getForObject(uri, PersonInfoDto.class);
//Here the object will contain only one value
ttId = 1408
rest values are returns null.
This is pom file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>msa</groupId>
<artifactId>MQA</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>MQA</name>
<description>MQA project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.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>
<orika-core.version>1.4.6</orika-core.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-web</artifactId>
</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>
<!-- https://mvnrepository.com/artifact/c3p0/c3p0 -->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<!-- Oracle JDBC driver -->
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Orika -->
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>${orika-core.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I removed the below entry from it worked.
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
But to map the RequestBody with XML data this dependency is required.
How can I solve this, which converter does rest template is using ? Can I force rest template to use a particular converter. ?
Hi Try adding #XmlRootElement on the PersonInfoDto class. And try once in web browser giving the URI which you are passing.

Why Spring Boot 1.4.0.RELEASE doesn't support LocalDateTime of Java 8 automatically

I have a Spring Boot application and I use LocalDateTime but I need to explicit configure the converter of Jsr310 for my LocalDateTime property:
Application.class (the main class)
#SpringBootApplication
#EntityScan(basePackageClasses = { Application.class, Jsr310JpaConverters.class })
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Entity example:
#Entity
public class News {
#Id
private Long id;
#JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
private LocalDateTime datetime;
...
Repository:
public interface NewsRepository extends JpaRepository<News, Long> {
#Modifying
#Transactional
#Query("DELETE FROM News n WHERE n.datetime < :datetime")
void deleteByDatetimeBefore(#Param("datetime") LocalDateTime datetime);
}
Pom file:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<description>Test</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<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-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</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>
Not should be automatic? Why I need configure this?
#EntityScan(basePackageClasses = { Application.class, Jsr310JpaConverters.class })
And why I need to write the delete Query:
#Query("DELETE FROM News n WHERE n.datetime < :datetime")
void deleteByDatetimeBefore(#Param("datetime") LocalDateTime datetime);
This should not be automatic like:
#Transactional
Long deleteByDatetimeBefore(LocalDateTime datetime);

Resources