java – How to write springboot job to listen for a result of a search page which is PHP

Sorry guys if it is trivial, but I have no idea how to write a spring boot job that searches in a PHP web page.

So there is a PHP web page, where you can find some search field and a button which will give you the results based on the search fields.

I have always the main URL, like https://some.page.com/subpage/searchforsomething.php#
Under F12 (with a browser) I can see the following:

Request URL: https://some.page.com/subpage/searchforsomething.php
Request Method: POST
Content-Type: application/x-www-form-urlencoded

and some Form Data which holds the search filters:

some_search(search_type)(living_search_type): somedummydata

And of course a lot of other data which maybe not necessary.

I know how to write REST API applications, but I have no idea how I could write some scheduled-code to listen to the results of a PHP search site.

So is it possible somehow?

java – High CPU usage in spring-boot application on linux servers

"Thread-28" #107 prio=5 os_prio=0 tid=0x00007f0ed0e15000 nid=0x67e9 runnable (0x00007f0e8f95d000)
   java.lang.Thread.State: RUNNABLE
    at sun.security.ssl.EngineArgs.init(EngineArgs.java:115)
    at sun.security.ssl.EngineArgs.<init>(EngineArgs.java:82)
    at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:762)
    at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
    at org.java_websocket.SSLSocketChannel2.unwrap(SSLSocketChannel2.java:150)
    - locked <0x0000000688019b18> (a org.java_websocket.SSLSocketChannel2)
    at org.java_websocket.SSLSocketChannel2.readRemaining(SSLSocketChannel2.java:254)
    at org.java_websocket.SSLSocketChannel2.readMore(SSLSocketChannel2.java:321)
    at org.java_websocket.SocketChannelIOHelper.readMore(SocketChannelIOHelper.java:28)
    at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:238)
    at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)
    at java.lang.Thread.run(Thread.java:748)

amazon ec2 – How can I connect My Domain and Spring-boot project?

my env : Linux, maven, AWS EC2, Spring boot

I can see the main screen of the project when I connect to the Elastic IP of EC2. However, when I try to connect to the purchased .dev domain, I get an 403 error and Test Page of Apache.

I think, maybe I didn’t enter the correct path. Or, The permission setting is incorrect.

So I modified the httpd.conf file, but it still doesn’t solve the problem. Can you check which one is wrong?

Please Check my Code

The path to the file that needs to be executed is in “/home/ec2-user/project/src/main/WEB-INF/views/home.jsp”.

etc/httpd/conf/httpd-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    DocumentRoot "/home/ec2-user"
    ServerName "test.dev"
    ServerAlias "www.test.dev"
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/test.dev/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/test.dev/privkey.pem
</VirtualHost>
</IfModule>

etc/httpd/conf/httpd.conf

# set IP addresses

Listen 80
    
<VirtualHost *:80>
    DocumentRoot "/home/ec2-user"
    ServerName "test.dev"
    ServerAlias "www.test.dev"
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.test.dev (OR)
    RewriteCond %{SERVER_NAME} =test.dev
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} (END,NE,R=permanent)
</VirtualHost>


# set Deny entirety <- default

<Directory />
    AllowOverride none
    Require all denied
</Directory>


# Directory custom setting

DocumentRoot "/home/ec2-user"

<Directory "/home/ec2-user">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/home/ec2-user">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

# Index position custom setting
<IfModule dir_module>
    DirectoryIndex /project/src/main/webapp/WEB-INF/views/home.jsp
</IfModule>

Error log

(core:error) (pid 7748) (13)Permission denied: (client XXX.XXX.XXX.XXX) 
AH00035: access to /project/src/main/webapp/WEB-INF/views/home.jsp denied 
(filesystem path '/home/ec2-user/project/src') because search permissions are 
missing on a component of the path

ec2-user’s permissions
enter image description here

project’s permissions
enter image description here

Reusable module using spring framework with spring-boot application modules?

I have a maven module which will handle DB interactions for various scenarios. I want this module to use spring framework so we can leverage the standard DI and integration test capabilities. This module will never run as it own application. Lets call this the DB module.

This module will be included as a dependency in a number of deployable application modules which use spring-boot to get easy access to various REST / Web interfaces. Lets call this will be the App module.

As I see it, the DB module will define the standard classes and @Autowire or @Resource JdbcTemplate objects. The integration tests of the DB module will define the full context for the module when running tests. I can use various test profiles at this level to switch between h2 and real DB’s.

In the App module, we’ll have a standard Config class which will declare the @Configuration annotation and then declare the various @Beans from the classes in the DB module.

Are there any guidelines or advise on how i should declare contexts or beans in these modules?

java – Como trabalhar com Classes que tenham outras Classes como atributo SpringBoot

Eae gente , essa é primeira vez que to programando pra web e to usando o spring boot pra isso , é um projeto da faculdade onde o FrontEnd vai ser feito em JS com React e o Back feito em JAVA com Spring . com o banco de dados postgres.
Eu fiquei com o Back end , e tudo ia bem até eu precisar trabalhar com classes compostas (classes que tem outras classes como atributo).
Tenho que fazer meio que uma lista de compra , uma Classe carrinho que tem como atributo um arrayList de compras , no qual compra tem como atributo um produto.

package com.api.springboot.model;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.hibernate.annotations.Cascade;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "carrinhos")
public class Carrinho implements Serializable {

    private static final long serialVersonUID = 1L;

    public Carrinho() {
        this.terminado = false;
    }


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String nome;
    private boolean terminado;
    private float precoTotal;


    @OneToMany
            //(cascade = CascadeType.ALL, mappedBy = "carrinhos")
    @JoinColumn(name = "carrinho_id")
    private List<Compra> compras = new ArrayList<>();

    @ManyToOne
    private Comprador comprador;

    @CreatedDate
    private Date criadoEm = new Date();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public boolean isTerminado() {
        return terminado;
    }

    public void setTerminado(boolean terminado) {
        this.terminado = terminado;
    }

    public float getPrecoTotal() {
        return precoTotal;
    }

    public void setPrecoTotal(float precoTotal) {
        this.precoTotal = precoTotal;
    }

    public void setCriadoEm(Date criadoEm) {
        this.criadoEm = criadoEm;
    }

    public List<Compra> getCompras() {
        return compras;
    }

    public void setCompras(List<Compra> compras) {
        this.compras = compras;
    }

    public void adicionarCompra(Compra compra){
        this.compras.add(compra);
    }

    public Date getCriadoEm() {
        return criadoEm;
    }

    public Comprador getComprador() {
        return comprador;
    }

    public void setComprador(Comprador comprador) {
        this.comprador = comprador;
    }

    public void add(Compra compra){
        compras.add(compra);
    }

    @Override
    public String toString() {
        return "Carrinho{" +
                "id=" + id +
                "n, nome='" + nome + ''' +
                "n, terminado=" + terminado +
                "n, precoTotal=" + precoTotal +
                "n, compras=" + compras +
                "n, comprador=" + comprador +
                "n, criadoEm=" + criadoEm +
                '}';
    }


}


package com.api.springboot.model;
import org.hibernate.annotations.ManyToAny;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.time.*;
import java.util.Date;

@Entity
@Table(name = "compras")
public class Compra implements Serializable {


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "produto_id")
    private Produto produto = new Produto();

    private int quantidade;
    private float precoTotal;

    @ManyToOne
    @JoinColumn(name = "carrinho_id")
    private Carrinho carrinho;

    @OneToOne
    private Promocao promocao;

    @CreatedDate
    private Date criadoEm = new Date();

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Produto getProduto() {
        return produto;
    }

    public void setProduto(Produto produto) {
        this.produto = produto;
    }

    public int getQuantidade() {
        return quantidade;
    }

    public void setQuantidade(int quantidade) {
        this.quantidade = quantidade;
    }

    public float getPrecoTotal() {
        return precoTotal;
    }

    public void setPrecoTotal(float precoTotal) {
        this.precoTotal = precoTotal;
    }

    public Date getCriadoEm() {
        return criadoEm;
    }

    public Promocao getPromocao() {
        return promocao;
    }

    public void setPromocao(Promocao promocao) {
        this.promocao = promocao;
    }

    public void setCriadoEm(Date criadoEm) {
        this.criadoEm = criadoEm;
    }

    public Carrinho getCarrinho() {
        return carrinho;
    }

    public void setCarrinho(Carrinho carrinho) {
        this.carrinho = carrinho;
    }

    @Override
    public String toString() {
        return "Compra{" +
                "id=" + id +
                ", produto=" + produto +
                ", quantidade=" + quantidade +
                ", precoTotal=" + precoTotal +
                ", carrinho=" + carrinho +
                ", promocao=" + promocao +
                ", criadoEm=" + criadoEm +
                '}';
    }
}


´´´
´´´
package com.api.springboot.model;

import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;

@Entity
@Table(name = "produtos")
public class Produto {
    private static final long serialVersonUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String nome;
    private float preco;
    private float peso;
    private boolean tipo;

    @ManyToOne
    private Categoria categoria;

    @CreatedDate
    private Date criadoEm = new Date();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() { return nome; }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public float getPreco() {
        return preco;
    }

    public void setPreco(float preco) {
        this.preco = preco;
    }

    public float getPeso() {
        return peso;
    }

    public void setPeso(float peso) {
        this.peso = peso;
    }

    public boolean isTipo() {
        return tipo;
    }

    public void setTipo(boolean tipo) {
        this.tipo = tipo;
    }

    public Date getCriadoEm() {
        return criadoEm;
    }

    public Categoria getCategoria() {
        return categoria;
    }

    public void setCategoria(Categoria categoria) {
        this.categoria = categoria;
    }

    @Override
    public String toString() {
        return "Produto{" +
                "id=" + id +
                ", nome='" + nome + ''' +
                ", preco=" + preco +
                ", peso=" + peso +
                ", tipo=" + tipo +
                ", categoria=" + categoria +
                ", criadoEm=" + criadoEm +
                '}';
    }
}

Essas são as 3 classes principais vou colocar somente o controlador de carrinho pois se me ajudarem com ele acredito que consigo usar a lógica para os outros.

package com.api.springboot.controllers;

import com.api.springboot.model.Carrinho;
import com.api.springboot.model.Compra;
import com.api.springboot.repository.CarrinhoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/api")
public class CarrinhoController {

    @Autowired
    CarrinhoRepository carrinhoRepository;

    @GetMapping("/carrinhos")
    public List<Carrinho> listarCompras(){
        return carrinhoRepository.findAll();
    }

    @GetMapping("/carrinho/{id}")
    public Carrinho carrinhoById(@PathVariable(value = "id") long  id){
        return carrinhoRepository.findById(id);
    }

    @PostMapping("/carrinho")
    public Carrinho salvarCarrinho(@RequestBody Carrinho carrinho){
        return carrinhoRepository.save(carrinho);
    }

    @DeleteMapping("/carrinho")
    public void deletaCarrinho(@RequestBody Carrinho carrinho){
        carrinhoRepository.delete(carrinho);
    }

    @DeleteMapping("/carrinho/{id}")
    public void deletetById(@PathVariable(value = "id")long id){
        carrinhoRepository.deleteById(id);
    }

    @PutMapping("/carrinho/put")
    public Carrinho atualizarCarrinho(@RequestBody Carrinho carrinho){
        return carrinhoRepository.save(carrinho);
    }


    @PostMapping("/teste/{id}")
    public void add(@PathVariable(value = "id") long id , @RequestBody Compra x){
        Carrinho instancia = carrinhoRepository.findById(id);
        System.out.println(instancia);
        System.out.println(x);
//        instancia.add();
//        carrinhoRepository.save(instancia);
//        System.out.println("Rodou o dream do dream quero");
//        System.out.println(instancia);
    }

}

A minha dúvida é , como que eu adiciono uma compra em carrinho . Eu tentei usar a compra x vindo do front como parâmetro e adicionar ela , só que ela vem nula.
inserir a descrição da imagem aqui
Aí uma foto de como chega , eu nunca usei injeção de dependências e todos os tutorias os professores só usam classes com atributos de tipo int,String,boolean …

spring – Erro ao executar aplicação Springboot

Gente, to com um problema pra iniciar minha aplicação e não to sabendo lidar…
Segue erro do console, seguido do conteúdo do meu arquivo application.properties:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-11 02:48:38.640 ERROR 1948 --- (  restartedMain) o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource (org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class): Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource (org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (com.zaxxer.hikari.HikariDataSource): Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:538) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:311) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) ~(spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~(spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~(spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~(spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at br.com.menagement.MenagementApplication.main(MenagementApplication.java:10) ~(classes/:na)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~(na:na)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~(na:na)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~(na:na)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~(na:na)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~(spring-boot-devtools-2.3.4.RELEASE.jar:2.3.4.RELEASE)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource (org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (com.zaxxer.hikari.HikariDataSource): Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    ... 27 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate (com.zaxxer.hikari.HikariDataSource): Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    ... 41 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.util.Assert.state(Assert.java:97) ~(spring-core-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:223) ~(spring-boot-autoconfigure-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:175) ~(spring-boot-autoconfigure-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~(spring-boot-autoconfigure-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:85) ~(spring-boot-autoconfigure-2.3.4.RELEASE.jar:2.3.4.RELEASE)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~(na:na)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~(na:na)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~(na:na)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~(na:na)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~(spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE)
    ... 42 common frames omitted

spring.datasource.url=jdbc:mysql://localhost:8080/casesystem
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

springboot – Spring Boot and stop by systemctl not working

My application uses Spring Boot 2.3.1.RELEASE, it is an executable jar that uses an Embedded Tomcat and is listening on port 10605.
I deployed on CentOS Linux release 7.6.1810 (Core).

I took the following steps:

  1. SPEEDYF.service creation

(Unit)

Description=SPEEDYF

After=syslog.target

(Service)

User=root

ExecStart=/usr/local/bin/SPEEDYF/SPEEDYF.sh

SuccessExitStatus=143

(Install)

WantedBy=multi-user.target

  1. creation of executable SPEEDYF.sh

#! / Bin / bash

sudo java -jar -Dspring.profiles.active = prod /usr/local/bin/SPEEDYF/SPEEDYF-0.0.1-SNAPSHOT.jar

For the first time the command: systemctl enable SPEEDYF.service
The start works correctly: systemctl start SPEEDYF.service

While the stop does not work properly: systemctl stop SPEEDYF.service.
That is, if I run the systemctl status SPEEDYF.service command I have the following output:

● SPEEDYF.service – SPEEDYF
Loaded: loaded (/etc/systemd/system/SPEEDYF.service; enabled; vendor preset: disabled)
Active: inactive (dead) ………

But the application is still running, that is, it writes the application logs and then verifying with the command:

lsof -i -P -n | grep LISTEN

the TCP port 10605 results in LISTEN.

The commands are executed with the root user.
I don’t understand what I can do to make the stop work properly.

Thanks in advance

Springboot (Java) – Is mandatory for BDD the use of Cucumber?

I was wondering if its a requirement to consider BDD the use of Cucumber framework or other framework of test abstraction.

Because I was playing around with @SpringbootTest and TestContainers(both compatibles with Cucumber) but I “discovered” the @DisplayName() on each test method/class and I thought that can “replace” cucumber, at least in the backend side.

I’m trying to avoid having a dedicated environment for acceptance/integration/regression tests at API level (considering a microservice system has everything dockerized) always with a controlled data set for each test.
Every microservice dockerized provide a default data to integrate tests.

Is this a mindblowing scope and I’m really wrong of wanting something like that? Would bring a lot of nightmare in the testing part for maintenance?

Java – Springboot: OAuth2 caches data? No data in the database, but authenticated

The truth is that something very, very strange is happening to me. Today I ended an authentication service with oauth2 with jwt. In my properties, I use "create-drop" to delete and create the database every time I stop and start my service (I use springboot). It turns out that when I tested my service, which calls it from the front end at an angle, I inserted data (which I had previously inserted into the database) and authenticated myself. This allows me to log in, but I have nothing in my database.

Evidence that the database has no data

As you can see in the picture, I have no data in my database, but ..

Enter the image description here

Using the Joaco username and password authenticates me, but there is nothing in my database !!
I would like to know if oauth2 processes some kind of cache or something like that because this problem really blew me away.