Tag Archives: maven

(error) READONLY You can‘t write against a read only replica.

Because the master-slave replication cluster was configured before, the configuration was changed disorderly

There are two solutions:

1. Open the configuration file corresponding to the redis service, and change the value of the attribute slave read-only to no, so that it can be written.

2. Open the client mode through the redis cli command, and enter the slave of no one command

How to Solve idea com.baomidou Error

Completely solve the error reported by com.baomidou in idea

Add in pom.xml:

		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus-boot-starter</artifactId>
			<version>3.4.2<ersion>
		</dependency>

Clear all mybatis and mybatis plus related configurations in the YML file and add:

mybatis-plus:
  type-aliases-package: com.peanut.entity
  mapper-locations: classpath:mappers

Select the item and right-click Maven -> Reload project
as shown in the figure, com.baidu no longer turns red:

[Solved] Mailsslsocketfactory error: Cannot find declaration to go to

1. Status. The 1.6.2 jar package is configured in Maven

The solution is to try to add Maven dependency again and replace the invalid jar package version

Finally, create the Lib package manually, copy the downloaded jar package to this directory, and then add it to the library. Add as library is successful

You have 77 PMD violations maven error [How to Solve]

Maven compilation exception

Failed to execute goal org.apache.maven.plugins:
maven-pmd-plugin:3.8:check (default) 
on project xxx: You have 133 PMD violations. 

Reason: PMD verification is added to Maven to judge whether your code complies with the specification. If it does not comply with the specification, an error will be reported when Maven compiles

Solution: how can this specification be removed? Just execute the following command, which can ignore the PMD check

mvn clean install -Dpmd.skip=true -Dcheckstyle.skip=true

Of course, when Maven compiles, there will be unit test execution, so how to ignore unit test execution?Just execute the following command

mvn clean install -Dmaven.test.skip=true

Therefore, as long as you want to ignore it, you can execute a command directly behind it
in a word:

In order to be compatible with errors, the following methods can be performed:

mvn clean install -Dpmd.skip=true -Dcheckstyle.skip=true -Dmaven.test.skip=true

[Solved] java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]

Error Messages:

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
.......
Caused by:
             org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
......
Caused by:
             java.lang.ClassCastException: class org.springframework.web.SpringServletContainerInitializer cannot be cast to class javax.servlet.ServletContainerInitializer (org.springframework.web.SpringServletContainerInitializer is in unnamed module of loader org.apache.catalina.loader.WebappClassLoader @1e0295e0; javax.servlet.ServletContainerInitializer is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @3d88e6b9)
......

 

cause:
I imported the following dependencies in the project’s pom.xml and found that the tomcat7 plugin can’t run
E.g:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
</dependency>
<dependency>
  <groupId>javax.servlet.jsp</groupId>
  <artifactId>javax.servlet.jsp-api</artifactId>
  <version>2.3.3</version>
</dependency>

Check:

1. Check whether the current port is occupied by the process

2. Check whether there is a problem with the servlet mapping URL path in web.xml

3. Check for dependency conflicts

reason:

The servlet dependent version imported in the current Maven configuration file is too high and incompatible with tomcat7

Solution:

The tomcat7 plug-in in pom.xml can be upgraded to tomcat8

reference:

<pluginRepositories>
  <pluginRepository>
    <id>alfresco-public</id>
    <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
  </pluginRepository>
  <pluginRepository>
    <id>alfresco-public-snapshots</id>
    <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
    <snapshots>
      <enabled>true</enabled>
      <updatePolicy>daily</updatePolicy>
    </snapshots>
  </pluginRepository>
  <pluginRepository>
    <id>beardedgeeks-releases</id>
    <url>http://beardedgeeks.googlecode.com/svn/repository/releases</url>
  </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat8-maven-plugin</artifactId>
      <version>3.0-r1655215</version>
      <configuration>
        <port>80</port>
        <path>/</path>
      </configuration>
    </plugin>
  </plugins>
</build>

last:

Refresh the Maven management tool, recompile the Maven project, and then start it with tomcat8!

Springboot Project Error: Failed to execute goal org.apache.maven.plugins

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources (default-resources) on project heima-leadnews-user: Error loading property file ‘D:\Develop\springboot_ project\heima-leadnews\heima-leadnews-user\maven_ test.properties’

When installing the springboot project, the above errors were compiled. Baidu’s reason is that the Maven version, JDK version and packaging program are occupied. My reason is that the parent project of the project has the following profiles:

<!--<profiles>
        <profile>
            <id>dev</id>
            <build>
                <filters>
                    <filter>maven_dev.properties</filter>
                </filters>
            </build>
        </profile>
        <profile>
            <id>test</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <filters>
                    <filter>maven_test.properties</filter>
                </filters>
            </build>
        </profile>
        <profile>
            <id>prod</id>
            <build>
                <filters>
                    <filter>maven_prod.properties</filter>
                </filters>
            </build>
        </profile>
    </profiles>-->

Because my child project inherits the parent project, but there is no corresponding directory under the child project, the above code in the parent project is cancelled (the specific reason is unknown, learning from the teacher), recompiled and packaged successfully

[Solved] Failed to configure a DataSource: ‘url‘ attribute is not specified…bug

Question page

Error message in log
no mybatis mapper was found in ‘[com. Ego]’ package. Please check your
configuration. Will not attempt to authenticate using SASL (unknown error)

Console output

Solution 1

Solution 1. I read many blogs, most of which are this solution. But it didn’t solve my problem

Solution 2

1. Because the versions of spring web and spring webmvc in POM are inconsistent, unify the dependent versions
2. If there are no database related things configured, comment out the POM dependencies of mybatis and MySQL first

I cited the problem caused by mapper’s Maven dependency in the consumermodel. Just delete it.

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

Problem: slf4j: failed to load class “org. Slf4j. Impl. Staticloggerbinder” error occurs when creating Maven project with idea for unit test

solution: add dependency in pom.xml. Because it is in the test environment, the scope tag is test. If it is running in main, you can change test.

<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>

[Solved] Mybatis-Plus Error: Invalid bound statement (not found)

Mybatis plus reports an error: invalid bound statement (not found)

After integrating mybatis plus in the spring boot project, it is found that the user-defined query method will report an error: “invalid bound statement (not found): * * *.” your method “, which means that your user-defined method cannot be found in the XML file. Various methods are tried and the problem is finally solved. This problem exists in the following situations:

1. Mapper file and XML file cannot correspond

1. Check whether mapper file and XML file names are consistent

UserMapper and UserMapper.xml

2. Check whether the attribute configuration of namespace in the XML file corresponds to the corresponding mapper file

<mapper namespace="com.*.*.mapper.UserMapper">

3. Check whether the method binding ID in the XML file is consistent

Mapper:
    List<User> getUserList();
xml:
    <select id="getUserList" resultType="com.*.*.entity.User">
        SELECT * FROM user
    </select>

2. The XML file is placed in the resources directory at different levels and is not packaged into the target

By default, all will be packaged. Check whether the property of not packaging is configured in the POM file, and modify it

Note: this configuration is to package the resources directory and check the differences

	<build>
        <!-- Pack the files in the resources directory -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>
        </resources>
     </build>

(focus on configuration, which is also my problem) third, the XML file is placed in the resources directory at different levels and has been packaged into the target, but the corresponding method cannot be found

It is thought that after packaging, you can match according to the name. Finally, it is found that even if the XML file is packaged, it still belongs to a different level from mapper, so check whether the mybatis plus configuration matching the location of the XML file is missing

mybatis-plus.mapper-locations = classpath:mapping/*.xml
# The "mapping" in this configuration corresponds to the name of the directory where your xml is located

An error is reported during Java operation due to the problem of static resource export

In this case, you need to add the following configuration in the pom.xml file

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

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