itstack-demo-design icon indicating copy to clipboard operation
itstack-demo-design copied to clipboard

在编译过程中遇到的一些问题

Open xkl700 opened this issue 4 years ago • 1 comments

环境 JDK1.8.0251+MAVEN3.6.1+IDEA ##[1]itstack-demo-design-8-02 报错信息为 错误: -source 1.6 中不支持 diamond 运算符 修改子项目下的pom.xml

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

##[2]itstack-demo-design-10-01 报错信息为 Cannot resolve org.itstack.demo.design.domain.UserInfo

我发现他打包的时候将itstack-demo-design-10-00项目的包打到了org.springframework.boot下 修改itstack-demo-design-10-00子项目下的pom.xml

    <!--修改前-->
    <packaging>war</packaging>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <!--修改后-->
   <parent>
        <artifactId>itstack-demo-design</artifactId>
        <groupId>org.itstack</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <packaging>jar</packaging>

另<dependencies></dependencies><groupId></groupId>的值为org.springframework.boot的都加上<version>2.1.2.RELEASE</version> ##[3]报错信息为 错误: -source 1.5 中不支持 diamond 运算符 Maven Compiler 插件默认会加 -source 1.5 及 -target 1.5 参数来编译(估计是为了兼容一些比较老的 Linux 服务器操作系统,它们通常只有 JDK 5),而我们的代码里使用了 JDK 7/8 的语法。

    <build>
        ...
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
        ...
    </build>

xkl700 avatar Jan 04 '21 01:01 xkl700

老哥 提个pr呀 我又躺了一遍

orangle avatar Jul 20 '21 09:07 orangle