Tag Archives: maven

Idea create Maven project Error: [error] no longer supports source option 1.5. Please use version 1.6 or higher, and the idea reports an error: error: Java does not support the error of release version 5

Project scenario:

As soon as the Maven project changes the POM file, the language level automatically becomes 5

Problem Description:

question 1: the Tomcat plug-in under move starts with an error
[error] the source option 1.5 is no longer supported. Please use version 1.6 or later
[error] target option 1.5 is no longer supported. Please use version 1.6 or later
idea error: error: Java does not support release version 5. This error


Cause analysis:

Maven is a project management tool. If you don’t tell it what JDK version to use for code compilation, it will be handled with the default JDK version of the compilation plug-in Maven compi ler plugin, which is prone to version mismatch, which may lead to failure of compilation


Solution:

to avoid this situation, the first step when building a maven project is to configure the Maven compiler plugin in the project POM XML file specifies the JDK version of the project source code, the compiled JDK version, and the encoding method

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>9</source>
          <target>9</target>
          <encoding>utf-8</encoding>
        </configuration>
      </plugin>


[Solved] IntelliJ idea error: error: Java does not support release 5

Method 1

1. Confirm to configure Maven

Find the path in Maven home path and find the Maven address \ conf \ setting xml

Select your own JDK version

<profile>
      <id>development</id>
      <activation>
        <jdk>1.8</jdk>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>

Restart idea

Method 2

In project POM Specify the JDK version in the XML file

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

Public Key Retrieval is not allowed [How to Solve]

Error reporting restore:

Public Key Retrieval is not allowed

Background description

MySQL 8.0Springboot

Error reporting solution

Add the following to the URL of the project configuration file:

allowPublicKeyRetrieval=true

Detailed demonstration

Open the application.yaml file of springboot.

The application.xml file generated by springboot by default is only in different formats, which means the same and does not affect. The SSM project finds the URL configuration in mybatis, which is the same. Add allowpublickeyretrieval = true at the end of the URL. Note that you need to connect with “&”.

# Springboot application.yaml File
# DataSource Config
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/vueadmin?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
    username: root
    password: 123456

[Solved] Mac Maven Command Error: zsh: command not found

The MVN command cannot be found under Zsh
If Maven is configured, you must execute source ~ /.Bash every time the terminal executes the MVN command_ Profile to take effect. This is because when Zsh is installed on the Mac,. The configuration of the Bash_profile file cannot take effect. The solution is:

vi ~/.zshrc

Add the following command at the end of the file:

source ~/.bash_profile
then
esc  :wq

Update document:

source ~/.zshrc

In this way, when Zsh starts, it will read. Bash_ The contents of the profile file and make it effective
configure Maven environment variables under Zsh
there are three places on the MAC where you can set environment variables:

/Etc/Profile: system global variable, which loads the configuration of the file upon system startup (not recommended)
/etc/bashrc: all types of bash shells will read the configuration of the file
~ /.Bash_Profile: configure user level environment variables and create them in the system user folder. When a user logs in, the file will be executed only once

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH=${PATH}:/usr/local/mysql/bin

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:/usr/local/maven/apache-maven-3.5.0/bin

export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.77
export PATH=$PATH:/CATALINA_HOME/bin

alias ll='ls -alF'
alias la='ls -A' 
alias l='ls -CF'

Then experiment

mvn -v 
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /Users/yaoyonghao/Documents/software/apache-maven-3.8.4
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

[Solved] O2oa compile error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin

O2oa6.3 reports an error in the idea compilation module

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project xxxx: Compilation failure

Solution: Change the JDK version of idea to 11 and synchronize the changes in pom.xml

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

[Solved] JPA sett in parameter error: Java.lang.illegalargumentexception

[error]

Java.lang.illegalargumentexception: encrypted array valued parameter binding, but was expecting [java.lang.string (n/a)]
JPA user-defined query statement fills the placeholder of in() with parameter value, and an error is reported

[reason]

The parameter value I passed in is of array type, but the in parameter value of JPA does not support array

[solution]

When setting the in parameter, the passed in parameter must be of type list.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testApplicat

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testApplication’: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.nos.test.TestApplication$$EnhancerBySpringCGLIB$$c1828724]: Constructor threw exception; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Invalid numeric type, found: STRING; nested exception is org.bson.BsonInvalidOperationException: Invalid numeric type, found: STRING

Question request: List all the course names that appear in the STUDENT collection (distinct)

 

 public List<String> test6_01(){
        Query query = new Query();
        List<Integer> list_course = mongoTemplate.findDistinct(query,"CID","student_course",Integer.class);
        System.out.println(list_course);
        List<String> list = new ArrayList<>();
        for(Integer i:list_course){
            Query query1 = new Query(Criteria.where("CID").is(i));
            Course course = mongoTemplate.findOne(query1,Course.class,"course");
            list.add(course.getNAME());
        }
        return list;
    }

Org.bson.bsoninvalidoperationexception: invalid numeric type, found: String prompts me to find the wrong data type. Only when the CID found is of string type can I find the data imported in the data. The CID is automatically set to string type.

Then let’s look at the specific usage of finddistinct() in mongodb: you can re query, but you can’t sort.

The method receives 4 or 5 parameters, respectively:

1 query criteria
2 fields to be de duplicated filed
3 collection database table to be queried
4 POJO instance corresponding to collection to be queried
5 return result class (return list of filed fields to be de duplicated)

After modification:

  public List<String> test6_01(){
        Query query = new Query();
        List<String> list_course = mongoTemplate.findDistinct(query,"CID","student_course",String.class);
        System.out.println(list_course);
        List<String> list = new ArrayList<>();
        for(String i:list_course){
            Query query1 = new Query(Criteria.where("CID").is(i));
            Course course = mongoTemplate.findOne(query1,Course.class,"course");
            list.add(course.getNAME());
        }
        return list;
    }

Query results:

Spring project import @Resource Annotation Error [How to Solve]

An error is reported after the @resource annotation is introduced into the spring project

Solution:

@Resource annotations are provided by J2EE

However, jdk1.9 and above versions need to import a javax.annotation dependency package from pom.xml in maven:

<dependencies>
    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>
</dependencies>

How to Solve AOP error in Spring

Error Messages:

java.lang.NoSuchMethodError: org.springframework.aop.scope.ScopedProxyUtils.isScopedTarget(java/lang/String;)Z

at org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:79)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:781)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.wt.test.AopTest.test1(AopTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)。

Solution:

Upgrade the AOP dependency in POM. It must be above version 4.0

 <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>4.2.2.RELEASE</version>
    </dependency>

[Solved] Maven executes servlet error: HTTP Status 500

An error is reported when the servlet executes and the dependency range is not written

Solution:

add the following code to pom.xml, mainly the dependency range provided

<dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

[Solved] java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest()…

Error message:

Page:

Back end:

java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest() accessible: module java.net.http does not "opens java.net.http" to unnamed module @621f89b8

Solution:

Change the parameters passed in the controller:   HttpRequest   ——》  HttpServletRequest