将.xml配置转换为spring boot application.properties

时间:2018-05-10 18:00:27

标签: java spring spring-boot

我正在将我的spring mvc项目转移到spring boot,我正在尝试将旧的.xml配置转换为应用程序属性。我只想出了jdbc和jsp属性。有什么想法吗?

.xml config

<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

发现这是另一种选择,但如果有人知道application.properties的设置

@Configuration
public class HibernateConf {

@Autowired
private EntityManagerFactory entityManagerFactory;

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

0 个答案:

没有答案