zoukankan      html  css  js  c++  java
  • Spring 工程搭建

    创建项目

    1.使用idea创建Maven工程

    • File————new————Project;
    • 查看JDK————选择Maven————Next;
    • 输入项目名:SpringDemoLiuJie————next;完成

    2.配置Maven

    • File————Settings————搜索Maven;
    • Maven home directory:选择安装路径——D:/Java/IntelliJ IDEA 2020.1/plugins/maven/lib/maven3
    • 勾选Overrid将setting文件位置及仓库位置改为自配置;
    • User settings file:maven安装路径confsetting.xml——D:Javaapache-maven-3.6.3apache-maven-3.6.3confsettings.xml
    • Local repository:maven安装路径 epository——D:Javaapache-maven-3.6.3apache-maven-3.6.3 epositor

    图解:

    搭建配置

    1, 引入依赖jar包

    Java基础包:libs目录的四个spring基础包

    网址:MavenRepository

    代码

    <dependencies>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-jcl -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jcl</artifactId>
    <version>5.2.13.RELEASE</version>
    </dependency>
    </dependencies>
    2.刷新Maven自动下载

    3.在srcmain
    esources下创建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:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util
    https://www.springframework.org/schema/util/spring-util.xsd
    ">

    <!-- bean definitions here -->
    <bean id="UserService" class="services.impl.UserServicelmpl"/>

    </beans>

    4.刷新
    提示:Application context not configured for this file————点Configure application context————ok


    测试
    接口类


    实现类


    实现接口并使用快捷键添加接口方法实现
    • Alt+Enter打开自动导入框
    • 选择第一个自动导入接口方法实现类
    测试类


    运行结果

















  • 相关阅读:
    Android 源码阅读之MMS细读TransactionService.java
    [Java2 入门经典]第16章 线程
    Android 源码阅读之建立3G网络流程
    从架构上看Android多媒体播放器
    Android 开发日志之仿三星Launcher
    非常适合OA系统的菜单
    模拟动网当前位置下拉菜单
    模拟windows菜单选项卡效果
    TreeView的各种操作
    ASCII表
  • 原文地址:https://www.cnblogs.com/Anm214/p/14585766.html
Copyright © 2011-2022 走看看