springBoot使用注解注入失败

useMapper的xml文件

 <mapper namespace="com.auto.dao.UserMapper">
    <select id="findByName" parameterType="String" resultType="User">
        select * from t_user where username=#{username}
    </select>
 </mapper>

mapper接口代码

public interface UserMapper {
    public User findByName(String username);
}

springboot启动类的代码

@SpringBootApplication
@MapperScan("com.auto.dao")
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }
}

pom.xml文件配置

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
  </parent>
  <groupId>com.auto</groupId>
  <artifactId>MavenDay01</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <java.version>1.8</java.version>
  </properties>
  <dependencies>
    <dependency>
        <!-- spirngBoot启动器 -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <!-- jstl -->
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.1</version>
    </dependency>

user的实体类

@Repository
public class User {
    private String username;
    private String password;
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Override
    public String toString() {
        return "User [username=" + username + ", password=" + password + "]";
    }

}

这是properties的配置文件

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mysql
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
mybatis.type-aliases-package=com.auto.entity  实体类和mapper.xml文件都在这包里面
server.port=9090

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

我写了个service接口,然后写了个实现类重写findByName方法返回userMapper中方法,在实现类中注入了userMapper接口,这里无法使用@Autowired注入

@Service
@Transactional
public class UserServiceImpl implements UserService{
    @Resource
    UserMapper userMapper;
    @Override
    public User findByName(String username) {

        return userMapper.findByName(username);
    }
}

报错

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.auto.dao.UserMapper.findByName

总是报找不到接口,加上注解标记也没用,换成在接口上用@mapper注解也不行,是什么问题,我在网上看说有什么依赖包冲突问题,但我换了几个版本也不行;

问题已经解决:
问题出在没有在properties文件中添加mapper.xml文件的扫描路径
解决办法:在properties文件中加上
mybatis.mapper-locations=com/.../.../*.xml 这里是mapper.xml文件的路径

2个回答

是否可以提供更多的代码? 比如UserMapper.xml? 在mapper接口中是否使用@param 注解?如果没有使用, 可能会导致找不到绑定参数的异常
如果使用的是idea 开发工具,请观察target 目录下的mapper 是否已经编译(mapper.xml是否存在) 如果没有编译, 请在pom 的build 中加入以下节点

<resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
</resources>

(这段依赖包含在build中)加入之后请重新Build

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=123456
spring.resources.static-locations=classpath:/static,classpath:/public,classpath:/resources,classpath:/META-INF/resources

# mapper 实现类路径
mybatis.mapper-locations=com/xdz/mybatis/mapper/impl/*.xml 

# mapper对应entity配置
mybatis.typeAliasesPackage=com.xdz.mybatis.entity   

weixin_43296748
API的Porter 回复qq_35929243: 您好,我在properties中加上了mapper_Location,代码可以成功运行了,浪费您这么多时间真是不好意思,非常感谢您的分享!
大约一年之前 回复
qq_35929243
qq_35929243 您将该配置补充到properties 中再尝试一下, (mybatis.type-aliases-package=com.auto.entity) 这个配置我也没用过 ,打算明天学习一下,如有问题, 希望您多多指教
大约一年之前 回复
qq_35929243
qq_35929243 我刚刚将您补充的配置文件再次看了一遍, 发现您没有配置实现类路径, 我将实现类路径代码配置注释之后,和您报的错是相同的,
大约一年之前 回复
qq_35929243
qq_35929243 十分抱歉未能模拟出您的问题, 我将我的配置文件放在回复中, 希望能对您有帮助 ,如有需要,我可以将Demo 发送至您的邮箱
大约一年之前 回复
weixin_43296748
API的Porter 回复qq_35929243:我在IDEA打开,xml文件确实没有,按照您的方法之后target目录下mapper.xml出现了,但是运行还是会那个错误
大约一年之前 回复
qq_35929243
qq_35929243 <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources>
大约一年之前 回复
qq_35929243
qq_35929243 如果您用的是IDEA , 请观察target 目录下mapper.xml 是否已经 编译 , 如果在target 目录下找不到mapper.xml , 请在build中加入如下依赖
大约一年之前 回复
weixin_43296748
API的Porter 我更新了,但是我参数只有一个,应该不需要这个注解吧
大约一年之前 回复

useMapper.xml中resultType="User" 的User在xml中定义了吗?

weixin_43296748
API的Porter 您好,问题确实是出在没有没有配置xml文件的路径,加上mapper_Location之后,代码可以正常运行,非常感谢您的分享!
大约一年之前 回复
sinat_30356443
云锦の 回复爱你久见你心: 这个是我写的代码示例 https://gitee.com/lshyunjin/publicProject/tree/master/dao
大约一年之前 回复
sinat_30356443
云锦の 回复爱你久见你心: 照着你的代码来了一遍,确实会报这个错,原因是你的properties里面没有读取mapper.xml文件,添加一个mybatis.mapperLocations=classpath:/*.xml配置就行了
大约一年之前 回复
weixin_43296748
API的Porter 我更新了代码,user实体类我就加了@Repository注解标记
大约一年之前 回复
sinat_30356443
云锦の 回复爱你久见你心: 有更多的代码吗,这个User是要映射的,即使properties写了,但是未必能映射吧
大约一年之前 回复
weixin_43296748
API的Porter mybatis.type-aliases-package=com.auto.entity这是我实体类的包 在properties文件里面配置了
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Springboot,使用@Autowired疑似注入失败,报空指针错误

项目结构: ![图片说明](https://img-ask.csdn.net/upload/202005/07/1588846375_795799.png) User类: ``` package com.test.mp.mp1111.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import org.springframework.stereotype.Component; @Data public class User { // @TableId(type = IdType.AUTO) private Long id; private Integer age; private String name; private String email; } ``` UserMapper: ``` package com.test.mp.mp1111.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.test.mp.mp1111.entity.User; import lombok.Data; import org.apache.ibatis.annotations.Mapper; import org.springframework.context.annotation.ComponentScan; import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; @Component public interface UserMapper extends BaseMapper<User> { } ``` Mp1111ApplicationTests: ``` package com.test.mp.mp1111; import com.test.mp.mp1111.entity.User; import com.test.mp.mp1111.mapper.UserMapper; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.List; @SpringBootTest class Mp1111ApplicationTests { @Autowired private UserMapper userMapper; @Test public void testUpdateById() { if (userMapper == null) { System.out.println("空指针"); } } } ``` 项目pom.xml ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.7.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.test.mp</groupId> <artifactId>mp1111</artifactId> <version>0.0.1-SNAPSHOT</version> <name>mp1111</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--mybatis-plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.5</version> </dependency> <!--mysql--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--lombok用来简化实体类--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>RELEASE</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ``` 我运行Mp1111ApplicationTests中的testUpdateById方法, 显示userMapper为空指针,这是为什么呀

springboot不能注入实体类?

使用1.5.3版本springboot,发现只能@autowired 接口,如果自动注入的是类,那自带的tomcat就启动不了,公司以前的包很多没用接口,一接上那些包就玩不了了 ,各位用什么方法解决的?

Springboot 工具类中注入Value失败

在工具类中,通过@Value的形式,获取配置失败,但是同样的写法在Controller中却成功了,而且在这个工具类的单元测试文件中也能获取到配置。 尝试在这个工具类上加入@Controller注解,@Service注解,@Component注解均无法获取。 补充说明:版本为springboot1.5.12,配置文件为yml文件 **问题找到了,在调用AuthUtil的类中,没有使用Spring容器管理,而是用了new创建的,所以导致出现这个问题。** ``` import lombok.Data; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RestController; @Component public class AuthUtil { private String timestamp; private String httpBody; @Value("${bindInfo.bind.secret}") private String secret; @Value("normal") private String normal; // 注入普通字符串 /* * 计算1970-01-01到当期时间的时间戳 */ public String getTimestamp() { long startPaintLogoTime=System.currentTimeMillis(); return String.valueOf(startPaintLogoTime / 1000); } public String getHttpMD5(String timestamp, String httpBody){ this.timestamp = timestamp; this.httpBody = httpBody; System.out.println(">>>>>>>>>>>>>>>>>>"+timestamp + secret +httpBody); System.out.println(normal); return DigestUtils.md5Hex( timestamp + secret +httpBody ).toUpperCase(); } public static void main(String[] args) { AuthUtil authUtil = new AuthUtil(); authUtil.getHttpMD5(authUtil.getTimestamp(),"ksksksks"); } } ``` ``` @RunWith(SpringRunner.class) @SpringBootTest public class AuthUtilTest { @Value("${bindInfo.bind.secret}") private String secret; @Test public void getTimestamp() { System.out.println(">>>>>>>>>>>>>>>>.."+secret); } } ```

springboot抽象类中注入实例,使用@Autowired注解托管实例,注入实例为空获取不到值的问题。

https://blog.csdn.net/loney_wolf/article/details/103505788 以上博客对springboot抽象类无法注入实例化做了解决,虽然解决了抽象类注入实体为空的情况,但是不知具体解决原理是什么。 </br> </br> </br> 抽象类不能实例化,因此在抽象类中不能注入其他实例,因为无法被spring托管。然而对抽象类的子类进行实例化托管之后,抽象类中进行注入托管的实例却能正正常注入,这是为什么(个人定位是java多态的向上向下转型)

springboot注入线程独立的bean

springboot像使用@autoWired注入httpServletrequest 这样的线程独立bean,每个线程都是自己的request 比如注入当前登录的用户对象,然后直接在Controller用注解获取这个用户.

spring boot单元测试时依赖注入失败怎么解决?

测试类 ![图片说明](https://img-ask.csdn.net/upload/201905/29/1559123110_583901.png) Controller类 ![图片说明](https://img-ask.csdn.net/upload/201905/29/1559123185_381071.png) 错误信息 ![图片说明](https://img-ask.csdn.net/upload/201905/29/1559123289_145321.png)

springboot+kotlin 使用@autowired 注解失败

学习kotlin时候,遇到注解失败。在注解dao的时候一直报错 报错信息如下: ``` Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-01-09 10:24:45.346 ERROR 13448 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appController': Unsatisfied dependency expressed through field 'appService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appService': Unsatisfied dependency expressed through field 'appDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cgs.hb.dao.AppDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at com.cgs.hb.DemoApplicationKt.main(DemoApplication.kt:20) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.0.RELEASE.jar:2.1.0.RELEASE] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appService': Unsatisfied dependency expressed through field 'appDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cgs.hb.dao.AppDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:273) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1239) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1166) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] ... 24 common frames omitted Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cgs.hb.dao.AppDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1646) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1205) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1166) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] ... 37 common frames omitted ``` 贴上代码: pom.xml如下: ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>app</artifactId> <version>0.0.1-SNAPSHOT</version> <name>app</name> <description>App project for Spring Boot</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <kotlin.version>1.2.71</kotlin.version> <authox-starter.version>1.0.9-beta</authox-starter.version> <hibernate.version>5.2.1.Final</hibernate.version> <dc-client-starter.version>1.1.9</dc-client-starter.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-kotlin</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-reflect</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jdk8</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>QRCode</groupId> <artifactId>QRCode</artifactId> <version>3.0</version> </dependency> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>3.6</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> </dependencies> <build> <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <configuration> <args> <arg>-Xjsr305=strict</arg> </args> <compilerPlugins> <plugin>spring</plugin> <plugin>jpa</plugin> </compilerPlugins> </configuration> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-allopen</artifactId> <version>${kotlin.version}</version> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-noarg</artifactId> <version>${kotlin.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> </project> ``` 实体类 ``` package com.cgs.hb.base import javax.persistence.Entity import javax.persistence.GeneratedValue import javax.persistence.GenerationType import javax.persistence.Id import javax.persistence.Table @Entity @Table(name = "app_info") data class AppInfos( @Id @GeneratedValue(strategy=GenerationType.AUTO) var id: Long?, var fileSize: String?, var filePath: String?, var fileName: String?, var version: String?, var uploadTime: String? ) { constructor() : this(null, null, null, null, null, null) } ``` dao ``` package com.cgs.hb.dao import com.cgs.hb.base.AppInfos import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository @Repository interface AppDao : JpaRepository<AppInfos, Long> { fun findByVersion(v: String): List<AppInfos> } ``` service ``` package com.cgs.hb.service import com.cgs.hb.base.AppInfos import com.cgs.hb.dao.AppDao import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service import javax.transaction.Transactional @Service("appService") @Transactional class AppService { @Autowired lateinit var appDao: AppDao fun saveInfo() { var app = AppInfos(1, "1MB", "c:\\app", "test.app","1.0.0","2018-12-01") appDao.save(app) } } ``` ``` package com.cgs.hb.controller import com.cgs.hb.service.AppService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/appInfo") @Api(description = "app") class AppController { @Autowired private lateinit var appService: AppService @GetMapping(value = "/saveInfo") @ApiOperation(value = "保存信息") fun saveInfo() { appService.saveInfo() } } ``` 增加启动类: ``` package com.cgs.hb import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration import org.springframework.cache.annotation.EnableCaching import org.springframework.data.jpa.repository.config.EnableJpaRepositories import org.springframework.scheduling.annotation.EnableScheduling import springfox.documentation.swagger2.annotations.EnableSwagger2 @SpringBootApplication(exclude = arrayOf(DataSourceAutoConfiguration::class, LiquibaseAutoConfiguration::class, HibernateJpaAutoConfiguration::class)) @EnableSwagger2 @EnableCaching @EnableScheduling class DemoApplication fun main(args: Array<String>) { SpringApplication.run(DemoApplication::class.java,*args) } ``` 代码结构: ![图片说明](https://img-ask.csdn.net/upload/201901/09/1547001180_732840.png) 各位大佬麻烦帮忙看下!!!

spring boot 切面 自定义注解无法使用在启动类的问题

我想使用spring boot 的切面进行对controller的返回进行统一处理,然后切点的要求是controller类,使用了自定义的启用注解(EnableGlobal),且未使用自定义的排除注解(ExcludeGlobal),但又不想在每个controller上面都写一个@EnableGlobal,想把@EnableGlobal写在启动类上面,但是不生效,各位大神有没有什么好的解决办法? ![图片说明](https://img-ask.csdn.net/upload/201901/20/1547954239_882510.png) ![图片说明](https://img-ask.csdn.net/upload/201901/20/1547954124_540916.png)

springBoot shiro 中 realm中注入service 使事务失效问题。

springBoot shiro 中 realm中注入service 使得 service的事务失效,如何解决。 在shiro的userRealm中 注入service时,导致注入的service没有事务(不会创建代理对象)。 ![图片说明](https://img-ask.csdn.net/upload/201805/18/1526636844_420952.png) ![图片说明](https://img-ask.csdn.net/upload/201805/18/1526636878_959306.png) 正常有事务的service 都应该是CGLI代理对象的。 应该怎么解决呢. 除了把 service改为dao,我需要事务

NettyServer注入失败,无法交给IOC托管

netty服务端需要跟DB交互 ``` @Component("nettyServer") public class MyServerHandler extends SimpleChannelInboundHandler<String> { @Autowired private CoreUserMapper userMapper; @Autowired private CoreRounduserMapper rounduserMapper; ``` 此处的俩mapper都为null 但是我在MyServerHandler里写个测试方法引用mapper内的方法,新建一个Controller然后@autowired注入这个MyServerHandler,断点进来这个mapper就不是空了,所以不是扫描路径的问题,我试过用service注解和@Component注解,还有在xml里bean注入都无法单独托管这个MyServerHandler

springboot2+shiro继承了LogoutFilter这个filter为什么不能@Bean注入

![图片说明](https://img-ask.csdn.net/upload/201906/19/1560944647_480864.png) ![图片说明](https://img-ask.csdn.net/upload/201906/19/1560944658_233519.png)![图片说明](https://img-ask.csdn.net/upload/201906/19/1560944667_439678.png)![图片说明](https://img-ask.csdn.net/upload/201906/19/1560944674_77238.png) 这个就是开源的若依框架,一共自定义了4个过滤器 为什么就是这个退出过滤器无法注入,这个异常到时是什么意思啊?求大佬帮忙指出一下。不对这个LogoutFilter加@Bean注解一切功能都是正常的,我就想知道为什么不可以加这个注解!

spring注入自动连接的依赖项失败,注解以及扫描都配好了,为什么 无法注入service?

![图片说明](https://img-ask.csdn.net/upload/201811/12/1542037550_716940.png)![图片说明](https://img-ask.csdn.net/upload/201811/12/1542037902_844706.png)![图片说明](https://img-ask.csdn.net/upload/201811/12/1542037921_69389.png)![图片说明](https://img-ask.csdn.net/upload/201811/12/1542037935_198421.png) ## service实现类 Controller调用service注入失败

springboot项目用junit进行单元测试,无法注入bean

这个是报错信息: ![图片说明](https://img-ask.csdn.net/upload/201903/25/1553483733_450518.png) org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cn.com.zhshzh.xs.pms.XsApplicationTests': Unsatisfied dependency expressed through field 'reimbursementInfoProcService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.com.zhshzh.xs.pms.system.test.service.ReimbursementInfoProcService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:400) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.com.zhshzh.xs.pms.system.test.service.ReimbursementInfoProcService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ... 29 common frames omitted 这个是测试类代码: package cn.com.zhshzh.xs.pms; import java.math.BigDecimal; import java.util.Date; import javax.ws.rs.core.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import cn.com.zhshzh.xs.pms.system.test.PO.ReimbursementInfoProc; import cn.com.zhshzh.xs.pms.system.test.service.ReimbursementInfoProcService; import lombok.extern.slf4j.Slf4j; // 获取启动类,加载配置,确定装载 Spring 程序的装载方法,它回去寻找 主配置启动类(被 @SpringBootApplication 注解的) @SpringBootTest(classes = Application.class) // 让 JUnit 运行 Spring 的测试环境, 获得 Spring 环境的上下文的支持 @RunWith(SpringRunner.class) @WebAppConfiguration @Slf4j public class XsApplicationTests { @Autowired private ReimbursementInfoProcService reimbursementInfoProcService; @Test public void TestCase() { ReimbursementInfoProc reimbursementInfoProc = new ReimbursementInfoProc(); reimbursementInfoProc.setProcessId("1"); reimbursementInfoProc.setPostId("1"); reimbursementInfoProc.setReimbursementPerson("23456"); reimbursementInfoProc.setReimbursementMoney(new BigDecimal("50.00")); reimbursementInfoProc.setReimbursementDate(new Date()); reimbursementInfoProc.setApprovalOpinion("审批通过"); reimbursementInfoProc.setCreateBy("23456"); reimbursementInfoProc.setUpdateBy("23456"); try { reimbursementInfoProcService.insertReimbursementInfo(reimbursementInfoProc); } catch (Exception e) { log.error("message", e); } } }

Spring整合Mybatis关于Dao注入失败的问题求解

抛出异常 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private pers.zww.grad.dao.IAdminDao pers.zww.grad.service.impl.AdminServiceImpl.adminDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [pers.zww.grad.dao.IAdminDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=adminDao)} 此为自动生成的Mapper,我加了注解@Repository package pers.zww.grad.dao; import org.springframework.stereotype.Repository; import pers.zww.grad.vo.Admin; @Repository("adminDao") public interface IAdminDao { int deleteByPrimaryKey(String id); int insert(Admin record); int insertSelective(Admin record); Admin selectByPrimaryKey(String id); int updateByPrimaryKeySelective(Admin record); int updateByPrimaryKey(Admin record); Integer getCountByName(String name); Integer getCountByNameAndPass(String name,String password); } 这是Service里面注入 package pers.zww.grad.service.impl; 、、、 @Service("adminService") public class AdminServiceImpl implements IAdminService { @Autowired @Qualifier("adminDao") private IAdminDao adminDao; @Override public int deleteByPrimaryKey(String id) { // TODO Auto-generated method stub return 0; } 配置文件都已扫描过了,而且相关mybatis的如下: <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:pers/zww/grad/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="pers.zww.grad.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean>

SpringBoot中@Autowired注入bean失败:Error creating bean with name“XXXController”?

# 报错信息: ``` org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizeController': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [E:\STS-WorkSpace\Forum\target\classes\com\Forum\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$141/1866850137.getObject(Unknown Source) ~[na:na] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE] at com.Forum.ForumApplication.main(ForumApplication.java:19) [classes/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [E:\STS-WorkSpace\Forum\target\classes\com\Forum\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$141/1866850137.getObject(Unknown Source) ~[na:na] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] ... 20 common frames omitted Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:123) ~[mybatis-spring-2.0.1.jar:2.0.1] at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73) ~[mybatis-spring-2.0.1.jar:2.0.1] at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) ~[spring-tx-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE] ... 31 common frames omitted ``` # Mapper代码: ``` package com.Forum.mapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import com.Forum.Model.User; @Mapper public interface UserMapper{ @Insert("insert into user (name,account_id,token,gmt_create,gmt_modified) values (#{name},#{accountId}),#{token},#{gmtCreate},#{gmtModified}") public void insert(User user); } ``` # 启动代码: ``` package com.Forum; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @ComponentScan(basePackages = {"com.Forum.*"}) @MapperScan(basePackages = {"com.Forum.mapper"}) public class ForumApplication { public static void main(String[] args) { SpringApplication.run(ForumApplication.class, args); } } ``` # Controller代码: ```package com.Forum.Controller; import java.util.UUID; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import com.Forum.Dto.AccesstokenDTO; import com.Forum.Dto.GitHubUser; import com.Forum.Model.User; import com.Forum.Provider.GitHubProvider; import com.Forum.mapper.UserMapper; @Controller public class AuthorizeController{ @Autowired private GitHubProvider gitHubProvider; @Value("${github.client.id}") private String clientId; @Value("${github.client.secret}") private String clientSecret; @Value("${github.redirect.uri}") private String redirectUri; @Autowired public UserMapper userMapper; @GetMapping("/callback") public String callback(@RequestParam(name="code") String code, @RequestParam(name="state") String state, HttpServletRequest request ) { AccesstokenDTO accesstokenDTO = new AccesstokenDTO(); accesstokenDTO.setCode(code); accesstokenDTO.setRedirect_uri("redirectUri"); accesstokenDTO.setClient_id(clientId); accesstokenDTO.setClient_secret(clientSecret); accesstokenDTO.setState(state); String accessToken = gitHubProvider.getAccessToken(accesstokenDTO); GitHubUser githubUser = gitHubProvider.getUser(accessToken); if(githubUser != null) { // 登录成功,写cookie和session User user = new User(); user.setToken(UUID.randomUUID().toString()); user.setName(githubUser.getName()); user.setAccountId(String.valueOf(githubUser.getId())); user.setQmtCreate(System.currentTimeMillis()); user.setQmtModified(user.getQmtCreate()); userMapper.insert(user); request.getSession().setAttribute("user", githubUser); return "redirect:/"; // 去掉地址后缀 }else { // 登录失败,重新登录 return "redirect:/"; } } } ```

关于spring boot注解的使用@Autowired

今天写代码的时候,在一个controller里面。有一个service死活是注解不了。 放在其他的控制器或者类里面都没有问题。后来一点点测试,发现了问题。 先show代码: 控制器 ``` @CrossOrigin @RestController @RequestMapping(value = "api/kpi/TOperLog", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public class TOperLogController { private Logger logger = LoggerFactory.getLogger(this.getClass()); private static final String TITLE = "OperLog"; private static final String TRUE = "true"; private static final String FALSE = "false"; @Autowired private TOperationlogService sysLogService; @AOPHandler(value = "查询") @GetMapping("/querylogbyid/{objectId}") public String querylogbyid(HttpServletRequest request, @PathVariable Integer objectId) { TOperationlogEntity obj = sysLogService.QueryOperLogById(1); return JSON.toJSONString(obj); } /** * 查询日志类型集合 * * @param request * @return */ @PostMapping("/QueryOperLogTypeList") private String QueryLogTypeList(HttpServletRequest request) { String requestURL = VerifyUtil.trimBaseHref(request.getRequestURL().toString()); try { List<String> list = sysLogService.QueryLogTypeList(); return RestfulTool.buildCollection(new ErrorInfo(TITLE, TRUE, JSON.toJSONString(list)), requestURL); } catch (Exception ex) { logger.error(String.format("内部服务器错误,修改积分计量规则失败: %s", ex.getMessage())); return RestfulTool.buildCollection(new ErrorInfo(TITLE, FALSE, "修改积分计量规则失败"), requestURL); } } /** * 获取操作日志 * @param request * @param type * @param page * @param pagesize * @return */ @PostMapping("/QueryOperLogList") private String QueryOperLogList(HttpServletRequest request,@RequestParam("type")String type,@RequestParam("page")Integer page, @RequestParam("pagesize")Integer pagesize){ String requestURL = VerifyUtil.trimBaseHref(request.getRequestURL().toString()); try { Pageable pageable=new PageRequest(page-1,pagesize); Page<TOperationlogEntity> pagelist= sysLogService.QueryOperLogList(type,pageable); return RestfulTool.buildCollection(new ErrorInfo(TITLE, TRUE, JSON.toJSONString(pagelist)), requestURL); } catch (Exception ex) { logger.error(String.format("内部服务器错误,获取操作日志失败: %s", ex.getMessage())); return RestfulTool.buildCollection(new ErrorInfo(TITLE, FALSE, "获取操作日志失败"), requestURL); } } } ``` 就是这个TOperationlogService 始终注解不了。经过排除法,是因为 @AOPHandler(value = "查询") 这个APO,去掉后正常注解。 百度后有人说如果有new的时候,就无法使用spring 来进行管理了。但是代码并没有new,下面是AOP的代码。里面也使用到了TOperationlogService,但是是通过注解方式。 ``` ** * 系统日志:切面处理类 */ @Aspect @Component public class SysLogAspect { @Autowired private TOperationlogService sysLogService; @Value("${tokenName}") private String tokenName; @Value("${tokenkey}") private String TokenKey; private Logger logger = LoggerFactory.getLogger(this.getClass()); //定义切点 @Pointcut //在注解的位置切入代码 @Pointcut(value = "@annotation(com.pcitc.sii.pfm.service.AOPHandler)") public void logPoinCut() { } /** * 控制器执行完成后,添加操作日志 * @param joinPoint */ @After("logPoinCut()") public void saveSysLog(JoinPoint joinPoint) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest(); try { TOperationlogEntity oplog = new TOperationlogEntity(); //从切面织入点处通过反射机制获取织入点处的方法 MethodSignature signature = (MethodSignature) joinPoint.getSignature(); //获取切入点所在的方法 Method method = signature.getMethod(); AOPHandler myLog = method.getAnnotation(AOPHandler.class); if (myLog != null) { String value = myLog.value(); oplog.setLogDec(value);//保存获取的操作 oplog.setLogTypeCode(myLog.opertype());//操作类型 } //读取session中存储的token,从token中获取用户的信息 String tokenstr = request.getHeader(tokenName); Claims claims = JwtUtil.parseJWT(tokenstr, TokenKey); oplog.setUserName(claims.get("username").toString()); oplog.setUserId(Long.parseLong(claims.get("id").toString())); oplog.setLogDate(new Date()); sysLogService.SaveOperLog(oplog); }catch (Exception ex){ logger.error(String.format("AOP切面内部错误:{%s}",ex.getMessage()) ); } } } ``` 有人给解释下为啥会出现这个情况吗

springboot+dubbo在写单元测试的时候controller中的@Reference注解属性为null

问题描述 项目中运用springboot+dubbo注解方式的配置开发,正常启动项目没有什么问题,但是当我在写单元测试的时候,发现@Reference标注的属性为null,导致调用空指针异常. 相关代码 待测试方法: ``` @RestController @RequestMapping("/api/user") public class UserController { @Reference(version = "${dubbo.service.version}") private IUserService userService; @PostMapping(value="/login", produces="application/json;charset=UTF-8") public JsonApi login(String username, String password) { User search = new User(); search.setUsername(username); User user = userService.selectUserBy(search); if (StringUtils.isEmpty(user)){ search.setUsername(null); search.setEmail(username); user = userService.selectUserBy(search); } if (StringUtils.isEmpty(user)){ throw new AuthorizeException(ErrorCode.USER_UNKNOWN_ACCOUNT); } return JsonApi.isOk()..data(user); } } ``` 测试方法: ``` @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @SpringBootTest public class UserControllerTest { private MockMvc mvc; @Before public void setUp() { mvc = MockMvcBuilders.standaloneSetup(new UserController()).build(); } @Test public void login() throws Exception { RequestBuilder request = post("/api/user/login") .contentType(MediaType.APPLICATION_JSON) .param("username","test") .param("password","123456"); String rs = mvc.perform(request) //.andDo(print()) .andExpect(status().isOk()) .andReturn() .getResponse() .getContentAsString(); System.out.println(rs); } } ``` 在运行测试用例的时候,发现private IUserService userService为空 ![图片说明](https://img-ask.csdn.net/upload/201809/26/1537953108_564995.png) 网上都是说和springMvc集成的时候加载顺序会导致这个空指针异常,但是我的项目正常启动是可以访问的,就是在测试用例的时候回出现空,不知道什么原因. 是哪里的配置没有配置对吗?

spring-boot2.16里面@Autowired 注入失败

@ConfigurationProperties 使用这个来生成配置类文件,但是总是注入失败 直接附上源码 [源码文件](https://pan.baidu.com/s/18h_U0Uy89SAcbnGNnqkR2g "")

service层是根据反射找到,然后new出来的,所以在service中用注解注入mapper无法生效,一直显示是null,如何解决

service层是根据反射找到,然后new出来的,所以在service中用注解注入mapper无法生效,一直显示是null,如何解决

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

立即提问
相关内容推荐