aligungun
2019-05-22 21:01 阅读 1.9k

spring boot 集成activiti如何能在启动时不配置数据库参数

<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
<!-- lookup parent from repository -->

com.example
leave
0.0.1-SNAPSHOT
leave
Demo project for Spring Boot


1.8



org.springframework.boot
spring-boot-starter-data-jpa


org.springframework.boot
spring-boot-starter-jdbc



org.springframework.boot
spring-boot-starter-web


mysql
mysql-connector-java
runtime


org.activiti
activiti-spring-boot-starter-basic
6.0.0


org.springframework.boot
spring-boot-starter-tomcat


org.springframework.boot
spring-boot-starter-web-services


org.springframework.boot
spring-boot-starter-test
test





org.springframework.boot
spring-boot-maven-plugin



------上面是spring boot 的pom.xml

在application.properties配置好数据库参数就可以正常运行。我的想法是在程序启动的时候不连接数据库,在程序运行的过程中按需连接到数据库,但我删除了数据可参数的时候就报错了!!!信息如下:

Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

在网上找到的解决方案是添加注解(分别如下尝试都出错):

1.-------------------------

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

@SpringBootApplication

2.---------------------------------------
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

3.------------------------------------
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

错误信息如下:

Description:
Parameter 0 of method springProcessEngineConfiguration in org.activiti.spring.boot.JpaProcessEngineAutoConfiguration$JpaConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.

  • Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
  • Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans

Action:
Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐