Приложение Vaadin23 неоднократно освежает при использовании Spring Session JDBCJAVA

Программисты JAVA общаются здесь
Anonymous
Приложение Vaadin23 неоднократно освежает при использовании Spring Session JDBC

Сообщение Anonymous »

Я строю приложение Vaadin 23 + Spring Boot 2.7 и пытаюсь интегрировать Spring Session JDBC для истечения сеансов после 1 минуты бездействия. < /p>
Проблема: < /strong>
Когда я запускаю приложение, браузер (Localhost: 8080) сохраняет чрезвычайно быстро. Если я прокомментирую зависимость весеннего сеанса, приложение работает нормально.
Вот что я сделал:

-добавленная зависимость пружины-сессии-jdbc
-inabletements it wair @enbchtpsession (maxinactiveIntervalinsconds = 60). /> -created Требуемые таблицы (spring_session, spring_session_attributes) < /p>
-Весифицированные записи сеанса создаются в db < /p>
-set spring.session.store-type = jdbc и server.servlet.session.timeout = 1m < /p> haill spring.session.jdbc.cleanup-cron временно
my code:
sessionConfig.java
import org.springframework.context.annotation.Configuration;
import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;

@Configuration
@EnableJdbcHttpSession(maxInactiveIntervalInSeconds = 60) // 1 minute for now
public class SessionConfig {
}
< /code>
application.properties:
# MySQL connection
spring.datasource.url=jdbc:mysql://localhost:3306/session
spring.datasource.username=root
spring.datasource.password=MyPassword

# Optional Hibernate tuning
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

# Session timeout (server-managed, complements JDBC)
server.servlet.session.timeout=1m

# Disable aggressive cleanup for now
spring.session.jdbc.cleanup-cron=0 */30 * * * * # every 30 mins
< /code>
mainview.java:

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.Route;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.flow.component.UI;

@Route("")
public class MainView extends VerticalLayout {

private final PersonRepository personRepository;
private final Grid grid = new Grid(Person.class);

public MainView(@Autowired PersonRepository personRepository) {

UI.getCurrent().setPollInterval(10000); // 10 seconds

this.personRepository = personRepository;

TextField firstNameField = new TextField("First Name");
TextField lastNameField = new TextField("Last Name");

Button addButton = new Button("Add", event -> {
Person person = new Person(firstNameField.getValue(), lastNameField.getValue());
personRepository.save(person);
updateGrid();
firstNameField.clear();
lastNameField.clear();
});

add(firstNameField, lastNameField, addButton, grid);

grid.setColumns("firstName", "lastName");
updateGrid();
}

private void updateGrid() {
grid.setItems(personRepository.findAll());
}
}
< /code>
Почему Ваадин продолжает освежать при включении пружинного сеанса?>

Подробнее здесь: https://stackoverflow.com/questions/796 ... ssion-jdbc

Вернуться в «JAVA»