1 Star 0 Fork 1

一神捞板 / spring_study

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

##常用依赖

  <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.9</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.9</version>
        </dependency>

<!--Junit-->
        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
              <version>4.13.2</version>
        </dependency>

注解说明

  • @Autowired : 自动装配通过类型。名字 如果Autowired不能唯一自动装配上属性,这需要通过@Qualifier(value="xxxx")
  • @Nullable: 字段标记了这个注解说明这个字段可以为null;
  • @Resource:自动装配通过名字,类型
  • @Component: 组件 放在类上,说明这个类呗Spring管理了,就是bean

##applicationContext.xml 模板

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd">

<!--    <bean id="user" class="com.zcs.pojo.User"/>-->

</beans>

##mybatis 核心配置文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<!--configuration核心配置文件-->
<configuration>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
                <property name="username" value="root"/>
                <property name="password" value="123456"/>
            </dataSource>
        </environment>
    </environments>
    <mappers>
        <mapper resource="org/mybatis/example/BlogMapper.xml"/>
    </mappers>
</configuration>

##mybatis Mappper模板

Empty file

About

学习spring写的代码 expand collapse
Java
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yishenlaoban/spring_study.git
git@gitee.com:yishenlaoban/spring_study.git
yishenlaoban
spring_study
spring_study
master

Search

344bd9b3 5694891 D2dac590 5694891