无法导入org.springframework.web.multipart.MultipartFile;

时间:2018-07-11 12:33:41

标签: spring spring-mvc multipartform-data

我正在使用spring boot for rest API。rest API的使用服务方法...对于服务方法,我有另一个项目-spring MVC应用程序。正在创建jar并将其提供给spring boot应用程序。我想在MultipartFile上写一些逻辑,但是问题是我无法在spring MVC应用程序(jar项目)中导入文件MultipartFile

看看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 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.wocs</groupId>
  <artifactId>services</artifactId>
  <packaging>jar</packaging>
  <version>0.1.36-SNAPSHOT</version>
  <name>services Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <properties>
        <org.springframework-version>5.0.3.RELEASE</org.springframework-version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <dependencies>

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>

  <!-- Spring framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.0.3.RELEASE</version>
    </dependency>

  <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.9</version>
    </dependency>

    <!-- Spring JDBC template -->
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>${org.springframework-version}</version>
      </dependency>

    <!-- log4j defined -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <!-- Apache Commons FileUpload --> 
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>

    <!-- Apache Commons IO --> 
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

 </dependencies>

我认为最后两个依赖项足以导入org.springframework.web.multipart.MultipartFile;

我缺少一些依赖吗?

请帮助我...预先感谢

1 个答案:

答案 0 :(得分:1)

只需在pom.xml中添加依赖项

<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.0.3.RELEASE</version>
</dependency>