GVKun编程网logo

Transactional cannot be resolved to a type

35

本文将带您了解关于Transactionalcannotberesolvedtoatype的新内容,另外,我们还将为您提供关于Android:OnClickListenercannotberesolv

本文将带您了解关于Transactional cannot be resolved to a type的新内容,另外,我们还将为您提供关于Android:OnClickListener cannot be resolved to a type、cannot be resolved to a type 解决方法!!!、Cannot resolve reference to bean ''entityManagerFactory'' while setting constructor argument、Cannot resolve reference to bean ''sqlSessionFactory'' while setting bean的实用信息。

本文目录一览:

Transactional cannot be resolved to a type

Transactional cannot be resolved to a type

SpringBoot整合Mybatis时遇到“ Transactional cannot be resolved to a type ” ,以为是没有导入相应的包 “ import org.springframework.transaction.annotation.Transactional; ” ,导入发现还是报错,在Stack Overflow上找到解决办法。在pom.xml中加入

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>4.2.6.RELEASE</version>
</dependency>

Android:OnClickListener cannot be resolved to a type

Android:OnClickListener cannot be resolved to a type

在看国外大师写的C++/C#这种语言类的书籍时,往往会对要using些什么都写的很清楚,但国内某本安卓书籍就没写这些……好吧,这些都太基础了,确实没必要写。不过我还是不知道遇到如题的问题该怎么办,于是找了下资料……

import android.view.View.OnClickListener;

版权声明:本文为 NoMasp柯于旺 原创文章,未经许可严禁转载!欢迎访问我的博客:http://blog.csdn.net/nomasp

cannot be resolved to a type 解决方法!!!

cannot be resolved to a type 解决方法!!!

小楼今天在做一个 Java 项目的时候遇到一个大家经常遇到的问题:XXX cannot be resolved to a type

看到一百多个 errors 时的时候,小楼也是被吓得赶紧去找度娘。


归纳一下小楼在网上看到的这种报错的主要的几种原因

1、jdk 不匹配(或不存在) 

2、jar 包缺失或冲突 

3、eclipse 查找项目类型策略所致 

相应的解决方案是:

1、jdk 不匹配(或不存在)时:例如项目指定的 jdk 为 “jdk1.6.0_18”,而当前 eclipse 使用的是 “jdk1.6.0_22”。需要在 BuildPath | Libraries,中做简单调整。 

2、jar 包缺失或冲突时:当找不到 “XX” 所在的 jar 包时,会报这个错。只需要找到对应 jar 包导入项目即可;另外,出现相同的 XX 时也会报此错,可能需要调包、解包、选删。  
3、eclipse 查找项目类型策略所致时 :  eclipse 下,上述两条都对比过了,没有任何问题,可偏偏还报这错。这时,需要操作一下 Project | Clean... ,问题即可解决。原因是,机制所致。因为某些特殊原因,eclipse 没能自动编译源代码到 build/classes(或其他 classes 目录),导致类型查找不到。


 

经分析,小楼的项目报错是由第二种原因所导致的,eclipse 没能找到相应的 jar 包。

于是,小楼就导入了相应的 jar 包。

具体步骤:

(1) 右键项目 —>BuildPath—>Configure Build Path—>Java Build Path—>Libraries

 

(2) 点击 Add JARs...

 

(3) 导入项目中 libs 下的相应的 jar 包

 

(4) 导入相应的 jar 包后点击 Apply

 

(5) 最后错误就解决了。

原文出处:https://www.cnblogs.com/kangbazi666/p/12085070.html

Cannot resolve reference to bean ''entityManagerFactory'' while setting constructor argument

Cannot resolve reference to bean ''entityManagerFactory'' while setting constructor argument

spring 5.+jpa 配置类出错:

十二月 20, 2018 5:53:01 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''studentRepository'': Cannot create inner bean ''(inner bean)#69ecc373'' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property ''entityManager''; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ''(inner bean)#69ecc373'': Cannot resolve reference to bean ''entityManagerFactory'' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ''entityManagerFactory'' available

原因之一是配置类中方法名不对:

@Bean
	public LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean()
	{
		//EntityManagerFactory
		LocalContainerEntityManagerFactoryBean bean=new LocalContainerEntityManagerFactoryBean();		
		bean.setDataSource(dataSource());
		bean.setPackagesToScan(new String[] {"com.jpa.demo"});
		bean.setJpaVendorAdapter(jpaVendorAdapter());
		return bean;
	}

  

必须是:entityManagerFactory:

@Bean
	public LocalContainerEntityManagerFactoryBean entityManagerFactory()
	{
		//EntityManagerFactory
		LocalContainerEntityManagerFactoryBean bean=new LocalContainerEntityManagerFactoryBean();		
		bean.setDataSource(dataSource());
		bean.setPackagesToScan(new String[] {"com.jpa.demo"});
		bean.setJpaVendorAdapter(jpaVendorAdapter());
		return bean;
	}

  

Cannot resolve reference to bean ''sqlSessionFactory'' while setting bean

Cannot resolve reference to bean ''sqlSessionFactory'' while setting bean

  今天下载公司以前的一个项目,要和现在的项目进行整合,下载一切顺利,但在开发机器上一跑,憋了。

  有两种日志,两种报错:一个是cannot resolve reference to bean ''sqlSessionFactory'' while setting bean,另一个报To prevent a memory leak, the JDBC Driver has been forcibly unregistered。

  乍一看怀疑是数据库没连接上,结果数据库是能联通的,又百度一同乱查,说什么的都有,最后找出原因,maven的pom文件中没有设置资源拷贝。

  原项目是用eclipse开发的,我用idea进行开发,使用maven作为项目管理平台,原本编辑器应该将项目中资源管理的权限全交个maven,但是使用eclipse开发时eclipse会插手,主动将src/java下的xml等资源文件拷贝到target下,由于eclipse多管了这么一宗闲事,时得当时的开发人员根本没注意pom中没有配置资源拷贝。

解决方法:在pom中设置资源拷贝即可

 1 <build>
 2     <resources>
 3         <!--编译后对xml进行资源拷贝-->
 4         <resource>
 5             <directory>src/main/java</directory>
 6             <includes>
 7                 <include>**/*.xml</include>
 8             </includes>
 9             <filtering>true</filtering>
10         </resource>
11     </resources>
12 </build>

关于Transactional cannot be resolved to a type的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android:OnClickListener cannot be resolved to a type、cannot be resolved to a type 解决方法!!!、Cannot resolve reference to bean ''entityManagerFactory'' while setting constructor argument、Cannot resolve reference to bean ''sqlSessionFactory'' while setting bean等相关知识的信息别忘了在本站进行查找喔。

本文标签: