• Maven工程继承关系,多个模块要使用同一个框架,它们应该是同一个版本,项目中使用的框架版本需要统一管理。


    1、父工程pom.xml

    1. "1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    5. <modelVersion>4.0.0modelVersion>
    6. <groupId>com.atguigugroupId>
    7. <artifactId>pro-ssmartifactId>
    8. <version>1.0-SNAPSHOTversion>
    9. <packaging>pompackaging>
    10. <modules>
    11. <module>pro04-spring-ioc-xmlmodule>
    12. modules>
    13. <properties>
    14. <maven.compiler.source>17maven.compiler.source>
    15. <maven.compiler.target>17maven.compiler.target>
    16. <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    17. <spring.version>6.0.6spring.version>
    18. <junit.version>5.3.1junit.version>
    19. properties>
    20. <dependencyManagement>
    21. <dependencies>
    22. <dependency>
    23. <groupId>org.springframeworkgroupId>
    24. <artifactId>spring-contextartifactId>
    25. <version>${spring.version}version>
    26. dependency>
    27. <dependency>
    28. <groupId>org.junit.jupitergroupId>
    29. <artifactId>junit-jupiter-apiartifactId>
    30. <version>${junit.version}version>
    31. <scope>testscope>
    32. dependency>
    33. dependencies>
    34. dependencyManagement>
    35. project>

    2、子工程pom.xml

    1. "1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    5. <modelVersion>4.0.0modelVersion>
    6. <parent>
    7. <groupId>com.atguigugroupId>
    8. <artifactId>pro-ssmartifactId>
    9. <version>1.0-SNAPSHOTversion>
    10. parent>
    11. <artifactId>pro04-spring-ioc-xmlartifactId>
    12. <properties>
    13. <maven.compiler.source>17maven.compiler.source>
    14. <maven.compiler.target>17maven.compiler.target>
    15. <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    16. properties>
    17. <dependencies>
    18. <dependency>
    19. <groupId>org.springframeworkgroupId>
    20. <artifactId>spring-contextartifactId>
    21. dependency>
    22. <dependency>
    23. <groupId>org.junit.jupitergroupId>
    24. <artifactId>junit-jupiter-apiartifactId>
    25. dependency>
    26. dependencies>
    27. project>

    3、Person.java

    1. package com.atguigu.ioc;
    2. public class Person {
    3. public void sayHello() {
    4. System.out.println("Hello Spring!");
    5. }
    6. }

    4、applicationContext.xml

    1. "1.0" encoding="UTF-8"?>
    2. <beans xmlns="http://www.springframework.org/schema/beans"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    5. <bean id="p01" class="com.atguigu.ioc.Person">bean>
    6. beans>

    5、PersonTest.java

    1. package com.atguigu.ioc;
    2. import org.junit.jupiter.api.Test;
    3. import org.springframework.beans.factory.BeanFactory;
    4. import org.springframework.context.support.ClassPathXmlApplicationContext;
    5. public class PersonTest {
    6. @Test
    7. public void test01() {
    8. new Person().sayHello();
    9. }
    10. @Test
    11. public void test02() {
    12. BeanFactory beanFactory = new ClassPathXmlApplicationContext("applicationContext.xml");
    13. Person p01 = (Person) beanFactory.getBean("p01");
    14. p01.sayHello();
    15. }
    16. }

  • 相关阅读:
    前后端分离
    Prompt Learning : Prefix Tuning
    【比特熊故事汇】6月MVP英雄故事|技术实践碰撞境界思维
    这次我设计了一款TPS百万级别的分布式、高性能、可扩展的RPC框架
    PADA: Example-based Prompt Learning for on-the-fly Adaptation to Unseen Domains
    java每日一记 —— List创建的方式判断
    操作系统期末复习题版详解(含解析)
    NoKia 8250维修笔记
    【python学习】-列表运算(列表元素均加减乘除某个数、两个列表间的运算、遍历列表等)
    手把手教你CSP系列之script-src
  • 原文地址:https://blog.csdn.net/m0_65152767/article/details/134515947