Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xkl700 opened this issue Jan 4, 2021 · 1 comment
Open

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

xkl700 opened this issue Jan 4, 2021 · 1 comment

Comments

@xkl700
Copy link

xkl700 commented Jan 4, 2021

环境 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>
@orangle
Copy link

orangle commented Jul 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants