目录
mybatis多数据源的原理是根据不同包,调用不同的数据源,只需要把mapper.java和mapper.xml写在某个package中,springboot自动帮你实现数据源切换,这个不要弄错
org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to process import candidates for configuration class [com.telecom.SpBookActApplication];
nested exception is java.io.FileNotFoundException: class path resource [org/springframework/security/config/annotation/authentication/configurers/GlobalAuthenticationConfigurerAdapter.class] cannot be opened because it does not exist
启动类中添加:
@SpringBootApplication(exclude = {
org.activiti.spring.boot.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]:Factory method 'entityManagerFactory' threw exception;
nested exception is java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
将配置文件Application.yml中的 url:jdbc:mysql… 改为:jdbc-url: jdbc:mysql…
Error creating bean with name 'bookInfoController': Unsatisfied dependency expressed through field 'iBookInfoService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'bookInfoServiceImpl': Unsatisfied dependency expressed through field 'baseMapper';
可能性1:实现类(XxxServiceImpl)没有加@Service注解,没有的话把这个注解加上。
可能性2:mapper类没有注入进去,可以在项目启动类上面加个全盘扫描或者指定扫描其下的任何包,注解使用它即可@MapperScan(“path”),其中path为扫描路径。
NoSuchBeanDefinitionException:
No qualifying bean of type ‘com.telecom.dao.BookDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
在写了mapper层的情况下还忘记删掉之前写的的dao层,导致重复了
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:564)
The following method did not exist:
'void org.apache.ibatis.session.Configuration.setDefaultEnumTypeHandler(java.lang.Class)'
这种一般都是由于版本依赖冲突引起的问题,用maven-helper检查一下依赖冲突,exclude一下,但是发现还是不行,但是删了本地重复的版本文件也不行。
jar:file:/D:/programs/apache-maven-3.6.1/mvn_resp/org/mybatis/mybatis-spring/2.0.6/mybatis-spring-2.0.6.jar!/org/mybatis/spring/SqlSessionFactoryBean.class
The called method’s class, org.apache.ibatis.session.Configuration, is available from the following locations:
jar:file:/D:/programs/apache-maven-3.6.1/mvn_resp/org/mybatis/mybatis/3.4.2/mybatis-3.4.2.jar!/org/apache/ibatis/session/Configuration.class
The called method’s class hierarchy was loaded from the following locations:
org.apache.ibatis.session.Configuration: file:/D:/programs/apache-maven-3.6.1/mvn_resp/org/mybatis/mybatis/3.4.2/mybatis-3.4.2.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.mybatis.spring.SqlSessionFactoryBean and org.apache.ibatis.session.Configuration
这是因为多个版本的依赖,找到mybatis-spring这个2.0.6依赖删除即可
java.lang.IllegalStateException:
Failed to introspect Class [com.telecom.config.PrimaryDataSourceConfig] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2f0e140b]
Caused by: java.lang.NoClassDefFoundError: org/apache/ibatis/session/SqlSessionFactory
Caused by: java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSessionFactory
这个报错其实就是没有找到要加载的类,一般在启动的时候报错。
加载不到的类有两种情况,一种是直接找不到要加载的依赖包,或者添加了依赖包后没有加载进入,需要看看是不是 maven 的设置问题,重新刷新加载一下 maven 的依赖,或者清一下 idea 的缓存;
另外一种是导入了依赖包,但是依赖包中又引入了其他的依赖包中的类,这个类找不到。
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:384)
com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver方法不存在
原因:activiti包中的 org.mybatis 包 和 mybatisPlus中的org.mybatis 包冲突。
需要排除掉activiti包中的 org.mybatis 包。
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
<exclusions>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
</exclusions>
</dependency>
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘deployApplications’ defined in class path resource [org/activiti/application/conf/ApplicationAutoConfiguration.class]:
Unsatisfied dependency expressed through method ‘deployApplications’ parameter 2;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘processEntryDeployer’ defined in class path resource [org/activiti/application/conf/ApplicationProcessAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘processEntryDeployer’ parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘repositoryServiceBean’ defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration/JpaConfiguration.class]: Unsatisfied dependency expressed through method ‘repositoryServiceBean’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘processEngine’ defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfiguration$JpaConfiguration.class]: Unsatisfied dependency expressed through method ‘processEngine’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘springProcessEngineConfiguration’ defined in class path resource [org/activiti/spring/boot/JpaProcessEngineAutoConfig
在创建SqlSessionFactoryBean bean = new SqlSessionFactoryBean();针对mybatis;若是项目中使用了mybatis,则需要替换成:MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); 否则会报错:找不到baseMapper中的方法;
Parameter 1 of method springProcessEngineConfiguration in org.activiti.spring.boot.JpaProcessEngineAutoConfiguration$JpaConfiguration required a bean of type 'javax.persistence.EntityManagerFactory' that could not be found.
// 第一种方式 指定工作流单独的数据源
@Configuration
public class ActivitiDatasourceConfig extends AbstractProcessEngineAutoConfiguration {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource.activiti")
public DataSource activitiDataSource() {
return DataSourceBuilder.create().build();
}
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor) throws IOException {
return baseSpringProcessEngineConfiguration(activitiDataSource(), transactionManager, springAsyncExecutor);
}
}
// 第二种方式 使用已有的数据源
@Configuration
public class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {
static final String NAME = "master";
//注入数据源和事务管理器
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
SpringAsyncExecutor springAsyncExecutor) throws IOException {
@Qualifier(NAME + "DataSource") DataSource dataSource,
@Qualifier(NAME + "TransactionManager") PlatformTransactionManager transactionManager,
return this.baseSpringProcessEngineConfiguration(dataSource, transactionManager, springAsyncExecutor);
}
}
此问题参考博客: https://blog.csdn.net/weixin_29300375/article/details/81181333
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
八成是application.yml文件中配置数据源啥的有问题
我是因为改动了配置数据源的路径spring.datasource.dynamic.datasource 后,但是忘记在项目的其他地方改一下这个配置文件中的路径
也可能是其他问题引起的:https://blog.csdn.net/qq_45498460/article/details/112860809
Could not update Activiti database schema: unknown version from database: '7.0.0.0'
这个可能是activiti下activiti-spring-boot-starter-basic包版本异常引起的数据库错误,需要如下图检查一下ProcessEngine.java里和数据库里的act_ge_property表里版本号是否一致,不一致的话将数据库中act_ge_property表中的版本号中的的版本和和pom.xml中activiti-spring-boot-starter-basic包下db.create下sql 文件中的版本对应。




这个问题也是苦苦寻找好久解决方法,最后参考的这个文章找到的这个解决办法https://blog.csdn.net/qq_41169544/article/details/122810066
,瞬间柳暗花明又一村了。
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun