SpringBoot 多模块 开发笔记(二)

  • 多模块 项目 打包
  • 点击 idea 左侧的 Maven 选择 生命周期
  • 点击 package 命令
尝试打包 出现 Unable to find main class
  1. 删除 主模块中的 打包插件
  2. 将打包插件 添加到 web 模块中
  • 以下是 web 模块中的 pom.xml 文件

<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.0modelVersion>
    <parent>
        <groupId>com.codervibegroupId>
        <artifactId>springbootmultimoduleartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <groupId>com.codervibegroupId>
    <artifactId>webartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <name>webname>
    <description>webdescription>
    <packaging>jarpackaging>
    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <maven.compiler.source>1.8maven.compiler.source>
        <maven.compiler.target>1.8maven.compiler.target>
    properties>
    <dependencies>
        <dependency>
            <groupId>com.codervibegroupId>
            <artifactId>serverartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
        <dependency>
            <groupId>com.codervibegroupId>
            <artifactId>modelartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>

    dependencies>
    <build>
        <finalName>springbootmultimodulefinalName>
        <plugins>
            
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <configuration>
                    <executable>trueexecutable>
                configuration>
            plugin>
        plugins>
    build>


project>

再次尝试打包

  • 出现 …Error creating bean with name ‘userController’ …
  • 报错信息太多 这里不在粘贴展示
  • 所有东西都找不到了
    1. 添加 applicationContext.xml 解决

<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"
       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/context 
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    
    <context:component-scan base-package="com.codervibe"/>
    <context:component-scan base-package="com.codervibe.model"/>
    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.codervibe.mapper"/>
    bean>

beans>

你可能感兴趣的:(前后端分离,JAVA,WEB,spring,boot,笔记,java)