1.idea Module is not specified 异常处理

问题通常出现在:当我们由于项目未知异常选择手动删除idea项目配置,并重启idea尝试使其生效时。

在File -> Project Structure -> Modules查看Modules信息,如果有删除,然后删掉项目重新建立即可。

2.Could not autowire. No beans of 'WeiXinAppServiceFeign' type found. less... (Ctrl+F1) 
Inspection info:Checks autowiring problems in a bean class.

Description:

Field weiXinAppServiceFeign in com.tx.servicemember.impl.MemberServiceImpl required a bean of type 'com.tx.servicemember.feign.WeiXinAppServiceFeign' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.tx.servicemember.feign.WeiXinAppServiceFeign' in your configuration.

 

尝试了各种方法,最后是qq上的同学提供了有效信息,注解问题。最终查出来的问题是注解使用错误:

启动类上:@FeignClients  更正为@EnableFeignClient

接口实现类上:增加@Service

3.Swagger2异常:java.lang.NumberFormatException:For input string:""

2019-01-07 18:23:03.830  WARN 21940 --- [nio-8080-exec-6] i.s.m.p.AbstractSerializableParameter    : Illegal DefaultValue  for parameter type integer

java.lang.NumberFormatException: For input string: ""
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_171]
	at java.lang.Long.parseLong(Long.java:601) ~[na:1.8.0_171]
	at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_171]
	at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) ~[swagger-models-1.5.20.jar:1.5.20]
	at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:654) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:157) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) [jackson-databind-2.6.5.jar:2.6.5]
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:157) [jackson-databind-2.6.5.jar:2.6.5]

解决方法:pom.xml中引入包

<dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.21</version>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
            <version>1.5.21</version>
        </dependency>

 4.The bean 'proxyRequestHelper', defined in class path resource

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-11 14:30:35.757 ERROR 31656 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'proxyRequestHelper', defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$NoActuatorConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$EndpointConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

出现此类错误是因为原因是SpringCloud与SpringBoot版本不一致。在pom.xml中增加

<!--管理依赖-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

5.Docker状态一直是Restarting,启动失败如何解决

idea node_modules发红 idea中module not specified_xml

查看日志,仔细查看问题,很多时候错误的提示不在第一行也不在最后一行,需要仔细去查找

docker logs 1d3e129052c2

idea node_modules发红 idea中module not specified_spring_02

原来是内存溢出造成docker进程被杀死,查看内存发现只有509M,一般容器需要2G的内存,只能升配内存了。

//查看服务器内存使用情况
free -mh

 

idea node_modules发红 idea中module not specified_spring_03

idea node_modules发红 idea中module not specified_java_04

6.解决maven上传jar包报错:Return code is: 400 , ReasonPhrase:Repository version policy

 出现场景:将maven项目打成jar包,发布到maven私有仓库时,报错Return code is: 400 , ReasonPhrase:Repository version policy;

原因:上传的jar包,版本信息中包含snapshot;

解决办法:<version>节点中去掉snapshot;

<groupId>com.hpm.blog</groupId>
    <artifactId>spring-boot-blog</artifactId>
    <!--<version>0.0.1-SNAPSHOT</version>-->
    <version>0.0.1</version>

7.springboot整合阿波罗,Located meta server address http://134.175.193.156:8080 for env UNKNOWN from com.ctrip.framework.apollo.internals.DefaultMetaServerProvider

-Denv=DEV

idea node_modules发红 idea中module not specified_xml_05

Init Apollo Local Config failed - namespace: application, reason: Load config from local config failed! [Cause: Cannot read from local cache file C:\opt\data\dhcc-shop-service-weixin\config-cache\dhcc-shop-service-weixin+default+application.properties]. 

Long polling failed, will retry in 1 seconds. appId: 8000000001, cluster: default, namespaces: application, long polling url: http://172.16.0.16:8080/notifications/v2?cluster=default&appId=8000000001&ip=172.18.40.193¬ifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out]

 Long polling failed, will retry in 1 seconds. appId: 8000000001, cluster: default, namespaces: application, long polling url: http://172.16.0.16:8080/notifications/v2?cluster=default&appId=8000000001&ip=172.18.40.193&notifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out]

idea node_modules发红 idea中module not specified_spring_06

腾讯云服务器得固定IP,EIP产品才可以在本机查看外网IP地址,强烈建议换阿里云,一个坑三天都在里面爬不出来

idea node_modules发红 idea中module not specified_xml_07

8.Consider defining a bean of type 'tx.common.core.utils.RedisUtil' in your configuration. 

tx.common.core.utils.RedisUtil'接口与对应实现类放在了与控制器所在包的同一级目录下,这样的@Component注解自然是无法被识别的 

有包冲突导致的,移入到同一个项目工程下。

9.The bean 'app-tx-weixin.FeignClientSpecification', defined in null, could not be registered

多个接口上的@FeignClient(“相同服务名”)会报错,overriding is disabled,即出现了相同的Bean名。

spring.main.allow-bean-definition-overriding=true

后面发现是这个,是因为Springcloud和Springboot版本不兼容

<!-- 管理依赖 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.M7</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

10.关于idea 中使用mybastis报出 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

如果是多个工程合并成一个工程的按如下步骤来:

1.搜索源工程中的xxxMapper.xml,看看这些文件是不是都copy到新工程对应的目录下

2.检查xml中的<mapper namespace="com.xxx.xxx" type="com.xxx.xxx"包路径是否正确

如果是自己加的mapper.xml,按如下步骤:

1.检查xml文件所在的package名称是否和interface对应的package名称一一对应

2.检查xml文件的namespace是否和xml文件的package名称一一对应

3.检查函数名称能否对应上

4.去掉xml文件中的中文注释

5.随意在xml文件中加一个空格或者空行然后保存

6.dao接口与xml的文件名不一致,接口名与Mybatis的映射文件名一定要一模一样。

7.*Mapper.xml文件放到resource文件夹下管理

11.Class.forName提示java.lang.ClassNotFoundException:

SpringBoot运行后一直提示java.lang.ClassNotFoundException:这个错误。当我传入的字符串是  完整的包名+类名,后面仔细比对发现传入的类名与实际不相符一定要仔细检查。

12.Exceptioninthread"main"java.lang.ClassNotFoundsException的问题

在部署Maven项目时报这个错误,是因为maven导出jar包时没有指定出口类,需要在pom文件中加入配置

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                    <mainClass>com.easytoolsoft.easyreport.web.WebApplication</mainClass>
                </configuration>
            </plugin>