/ / Conversion de la configuration .xml en Spring Boot application.properties - java, spring, spring-boot

Convertir la configuration .xml en print boot application.properties - java, spring, spring-boot

je transfère mon projet de printemps mvc au printempsboot et j’essaie de convertir la configuration .xml de l’ancienne école en propriétés d’application.J’ai seulement compris les propriétés jdbc et jsp. Des idées?

configuration .xml

<bean id="trans"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<tx:annotation-driven transaction-manager="trans" />

<mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources>

application.properties

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/?useSSL=false
spring.datasource.username=root
spring.datasource.password=asdf
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

spring.mvc.view.prefix:/WEB-INF/views/
spring.mvc.view.suffix:.jsp

trouvé cela comme une alternative, mais si quelqu'un connaissait le paramètre pour application.properties

@Configuration
public class HibernateConf {

@Autowired
private EntityManagerFactory entityManagerFactory;

@Bean
public SessionFactory getSessionFactory() {
return entityManagerFactory.unwrap(SessionFactory.class);
}

Réponses:

0 pour la réponse № 1

Les beans ne peuvent pas être définis dans application.properties, je suppose. Doit être dans une classe avec l'annotation @configuration, bean avec @bean.