Problems and solutions in Maven learning

I just got started with Maven recently, and I encountered some problems during the learning process. In this sharing, it may be of some help to you.

(1) As soon as the Maven project updates the jdk version, it will become 1.5?

Add the compiler version plugin in the pom.xml file

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <encoding>UTF-8</encoding>
     </configuration>
</plugin> 

Right-click the project->Properties->Java Build Path and change the jdk to 1.7, and then synchronize the java version to 1.7 in Project Facets, and then update the project and it will become 1.7

 

(2) Maven integrates the SSM framework, and the generated project generates java.lang.AbstractMethodError:  org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer error at runtime

This is a version problem. The integration of MyBatis3.x and Spring4.x is to import MyBatis-Spring.jar to use version 1.3.x or above. I imported 1.3.2 and it ran successfully

 

(3) Using the SSM framework, the corresponding mapper configuration file is not generated when the Maven project is packaged into a war package


Do the following configuration in pom.xml

<resources>
  <resource>
    <directory>src/main/resources</directory>
    <includes>
      <include>**/*.properties</include>
      <include>**/*.xml</include>
      <include>**/*.tld</include>
      <include>**/*.jsp</include>
    </includes>
    <filtering>true</filtering>
  </resource>

  <resource>
    <directory>src/main/java</directory>
    <includes>
      <include>**/*.properties</include>
      <include>**/*.xml</include>
      <include>**/*.tld</include>
    </includes>
    <filtering>true</filtering>
  </resource>
</resources>

This configuration is to synchronize some configuration files in the java path and resources path to the generated war package

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738149&siteId=291194637