zoukankan      html  css  js  c++  java
  • Spring-常用依赖及配置

    ##常用依赖
    ```xml
    <dependencies>
    <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.4.5</version>
    </dependency>

    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.15</version>
    </dependency>

    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    </dependency>

    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
    </dependency>

    <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    <version>1.9.2</version>
    </dependency>

    <dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1</version>
    </dependency>

    <dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.8</version>
    <scope>provided</scope>
    </dependency>

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

    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.9.1</version>
    </dependency>
    </dependencies>
    ```
    ##注解说明
    - 都是用来自动装箱的,都可以放在属性字段上
    - 如果类型和名字都找不到的情况下,就会报错
    - @Autowired :自动装箱通过类型,名字【区别:有提示信息】【常用】
    如果Autowired不能唯一自动装配上属性,则需要通过@Qualifier(value="xxx")
    - @Nullable:字段标记了这个注解,说明这个字段可以为null
    - @Resource : 自动装配通过名字,类型【区别:没有提示信息】
    ##Spring常用配置
    ```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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <context:component-scan base-package="cn.scitc.pojo"></context:component-scan>


    <bean id="cat" class="cn.scitc.pojo.cat"/>
    <bean id="dog" class="cn.scitc.pojo.dog"/>
    <!--<bean id="cat11" class="cn.scitc.pojo.cat"/>-->
    <!--<bean id="dog11" class="cn.scitc.pojo.dog"/>-->
    <bean id="person" class="cn.scitc.pojo.person"/>

    </beans>
    ```
  • 相关阅读:
    python 语言打印直角三角形的几种方法
    python基础练习,循环、列表、字典、数组
    python命令行运行django项目, can't open file 'manage.py' 问题解决
    python数组列表、字典、拷贝、字符串
    Python输入与循环
    Python实现制度转换(货币,温度,长度)
    Matlab中图论工具箱的应用
    eclipse环境下日志打印输出
    mxGraph上下级节点与连线高亮显示代码
    mxgraph菜单配置及读取菜单节点名称方法
  • 原文地址:https://www.cnblogs.com/wpy188/p/12391322.html
Copyright © 2011-2022 走看看