首页 > 解决方案 > 主类没有完成启动应用程序 spring Java

问题描述

我正在尝试在 Eclipse 中启动我的 Spring 应用程序,但是当我选择 RightBtn --> Run as --> Spring boot App 时,执行启动过程似乎并没有完成。事实上,eclipse 正在部署我的应用程序,我可以通过 REST ( http://localhost.. ) 与它进行交互。但是当我看到控制台时,我看到它在完成读取 main 方法时停止在控制台中打印消息。(我把日志放在结果部分)

我试图弄清楚为什么会发生这种情况,因为通常当我启动一个 Spring 应用程序时,我会得到类似于我在输出部分中发布的内容:

我认为它与 bean 声明无关,因为我在日志中看到了以下内容:

'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7738e7d1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

正如我在下面的链接中看到的(类不符合所有 BeanPostProcessors 处理的资格),我不应该担心它。所以不知道问题出在哪里。

我已经尝试了很多东西,评论了我包含的一些标签,但仍然是同样的问题。我想我混合了太多标签,所以在某些时候我的应用程序无法继续并且没有显示任何错误。

我认为我错了,所以我决定从 git ( https://github.com/igorkosandyak/spring-boot-kafka ) 下载代码,以观察真正的输出应该是什么样子。

package com.lexcorp.appianSer;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.lexcorp.trazas.*;//traerte la clase de trazas 

import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.PropertySource;


import com.lexcorp.config.AppPropert;
import com.lexcorp.config.ConfProp;
import com.lexcorp.config.ServerProperties;
import com.lexcorp.filters.*;
import com.lexcorp.productor.ProducerConsumerApplication;

import org.apache.log4j.Logger;//ojo porque en el repo la clase de logger esta apuntada como com.springsource.org.apache.log4j 
import org.springframework.context.annotation.ComponentScan;//tengo que decalara especificamente el bean invocado porque si no da error 
import org.springframework.context.event.ContextRefreshedEvent;//importar p`ropiedad para evento 
import org.springframework.context.event.EventListener;//importar las propiedades para escuchar eventos 
import org.springframework.scheduling.annotation.Async;//tratamos de hacer que la llamada al metodo sea asincrona al código
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.boot.context.event.ApplicationReadyEvent;//importar eventos para ejecuccion tras el final del main



@PropertySource("classpath:application.yml")
@RestController
@SpringBootApplication
@EnableZuulProxy
@ComponentScan("com.lexcorp.config")
@EnableScheduling
public class ControllerFPC {


    static Properties props;
    static String servletContext;
    static String propertiesName;
    final static Logger logger = Logger.getLogger(ControllerFPC.class);

    @Autowired
    ServerProperties conf;

    @Autowired
    private ConfProp configurationData;

    @Value("${name}")
    private String name;/**/

    @Value("${app.topic.fpc}")
    private String topic;//esta es nueva para los valores mas complicados de recuperar que acumulan secciones y subsecciones

    @Value("${spring.kafka.consumer.bootstrap-servers}")
    private String bootstrapServers;//@Value("${spring.kafka.bootstrap-servers}")//configuracion antigua de como se leia el servidor para el consumidor

    @Value("${spring.kafka.consumer.group-id}")
    private String groupid;/*invocamos el grupo donde vamos a incluir al grupo consumidor */

    //auto-offset-reset
    @Value("${spring.kafka.consumer.auto-offset-reset}")
    private String autooffsetr;/*invocamos el grupo donde vamos a incluir al auto-offset-reset consumidor para la politica de lectura de mensajes  */

    //key-deserializer
    @Value("${spring.kafka.consumer.key-deserializer}")
    private String keydeserial;/*invocamos el grupo donde vamos a incluir al deserializador de los mensajes consumidor */

    //value-deserializer
    @Value("${spring.kafka.consumer.value-deserializer}")
    private String valuedeserial;/*invocamos el grupo donde vamos a incluir al deserializador de los mensajes consumidor */


    @RequestMapping(value = "/available")
      public String available() {
        //startKafka();
        System.out.println("EStoy disponible");
        return "Spring in Action";// url http://localhost:8082/available

      }

    @RequestMapping(value = "/kafka")
      public String startKafka() {

        /*ProducerConsumerApplication pca= new ProducerConsumerApplication();
        pca.consumerStart();*/

        AppPropert prope= new AppPropert();
        props=prope.arranqueProp();
        ProducerConsumerApplication pca= new ProducerConsumerApplication();

        //pca.execute(topico,"Enviamos mensajes desde findById");//no funciona este emtodo 
        pca.readTop(props, "Procedemos a activar la lectura");

        return "Spring in Action";// url http://localhost:8082/available
      }

    @RequestMapping(value = "/deletecell")
      public String postit() {// url http://localhost:8082/deletecell

        HttpClient httpClient = HttpClientBuilder.create().build(); //Use this instead 

        try {//iniciamos la configuracion en el momento inicial del evento 
            ControllerFPC con= new ControllerFPC();
            props=con.setProperties(props, conf);//rellenas el fichero de propiedades 

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println(e.getMessage());
            logger.error("Exception : ControllerFPC.calculateLoadVal en la lectura del fichero de propiedades  " + e.getMessage());
        }

        try {

            HttpPost request = new HttpPost("http://localhost:8082/borrar");
            StringEntity params =new StringEntity("appians={\"id\":392,\"idlo\":LoadRegister} ");//new StringEntity("details={\"id\":\"aa\",\"idlo\":\"aaa\"} ");
            request.addHeader("content-type", "application/x-www-form-urlencoded");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);

            //handle response here...

        }catch (Exception ex) {

            //handle exception here

        }

        return "Spring in Action";// url http://localhost:8082/available
      }





    @RequestMapping(method = RequestMethod.POST, value = "/borrar")
    @ResponseBody
    public String findById(
      @RequestParam String appians, HttpServletRequest req, HttpServletResponse res) {//@PathVariable long id
        ; 
        try {
            String topico=topic;
            ControllerFPC con= new ControllerFPC();
            props=con.setProperties(props, conf);//rellenas el fichero de propiedades 

            props=con.setPropiedades(props, bootstrapServers, topic);// incluyes groupid,  autooffsetr, keydeserial ,valuedeserial


        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println(e.getMessage());
            logger.error("Exception : ControllerFPC.calculateLoadVal en la lectura del fichero de propiedades  " + e.getMessage());
        }

        String answer = appians.substring(appians.indexOf(":")+1,appians.indexOf(","));
        System.out.println(" has entrado en post recibir"+appians+ " extraccion --> "+answer);
        ServletFPC srv = new ServletFPC();
        String resultborrar=srv.borrarReg(answer,servletContext, propertiesName, logger, props);
        return "exito"+resultborrar;
    }




    public static void main(String[] args) {
        // TODO Auto-generated method stub
        servletContext=System.getProperty("catalina.home");
        propertiesName="config.properties";
        if(servletContext==null) {
            //la ruta antigua era en 
            //servletContext="aqui tenia la ruta absoluta";
        }
        servletContext=servletContext+"/instances/facturacioncorp001/webapps/";//La ruta linux es: "//instances//facturacioncorp001//webapps//properties//config.properties"
        ControllerFPC con= new ControllerFPC();
        props = new Properties();



        SpringApplication.run(ControllerFPC.class, args);



        logger.info("Starter of APP  " );


        System.out.println(" Finnish starting process ");

    }
    /*
    @Async @EventListener(ContextRefreshedEvent.class)//ContextRefreshedEvent.class --> se lanza justo despuesd e que se creen todos los beans pero antes de que se inicie el servidor  , ApplicationReadyEvent.class)
    public void doSomethingAfterStartup() {
        System.out.println("hello world, I have just started up");
    }*/
    /*@Scheduled(fixedDelay = 10000, initialDelay = 10)
    public void execDel() {
        System.out.println("Starting scheduled activity ");
        AppPropert prope= new AppPropert();
        props=prope.arranqueProp();
        ProducerConsumerApplication pca= new ProducerConsumerApplication();

        //pca.execute(topico,"Enviamos mensajes desde findById");//no funciona este emtodo 
        pca.readTop(props, "Procedemos a activar la lectura");
    }*/


    @Bean
    public PreFilter preFilter() {
        return new PreFilter();
    }
    @Bean
    public PostFilter postFilter() {
        return new PostFilter();
    }
    @Bean
    public ErrorFilter errorFilter() {
        return new ErrorFilter();
    }
    @Bean
    public RouteFilter routeFilter() {
        return new RouteFilter();
    }/**/

    @GetMapping("/datos")
    public ConfProp retrieveDatosFromConfigurations() {
        return configurationData;
    }

    public Properties setProperties(Properties props,ServerProperties conf) {

        try {
        props.setProperty("name", conf.getname());
        props.setProperty("environment", conf.getenvironment());
        props.setProperty("ORACLE_CHECK", conf.getORACLE_CHECK());
        props.setProperty("UPLOAD_SFTP", conf.getUPLOAD_SFTP());
        props.setProperty("SFTPUSER", conf.getSFTPUSER());
        props.setProperty("SFTPPASS", conf.getSFTPPASS());
        props.setProperty("TRAZA", conf.getTRAZA());
        props.setProperty("WSDL", conf.getWSDL());
        props.setProperty("REDIR", conf.getREDIR());
        props.setProperty("FSDIR", conf.getFSDIR());
        props.setProperty("DOWN_DIR", conf.getDOWN_DIR());
        props.setProperty("SOAPACTION", conf.getSOAPACTION());


        logger.info("Se ha completado la lectura del fichero de configuracion del config-server ControllerFPC.setProperties" );
        }catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            //myLog.escribir(m1.toString()+"Exception: Error en metodo ServletFPC.crearConsulta no se ha enviado la request correctamente "+e.getMessage());
            logger.error("Exception: ControllerFPC.setProperties ha fallado la lectura del ficehro de configruacion colgado en el config server  " + e.getMessage());
        }
        return props;
    }
    public Properties setPropiedades(Properties props,String bootstrapServers, String topic) {
        try {

            props.setProperty("bootstrap-servers", bootstrapServers);
            props.setProperty("topic", topic);


            logger.info("Se ha completado la lectura del fichero de configuracion del config-server ControllerFPC.setProperties" );
            }catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                //myLog.escribir(m1.toString()+"Exception: Error en metodo ServletFPC.crearConsulta no se ha enviado la request correctamente "+e.getMessage());
                logger.error("Exception: ControllerFPC.setPropiedades ha fallado la lectura del fichero de configruacion colgado en el config server  " + e.getMessage());
            }


        return props;
    }
    public Properties arranquePropiedad(String bootstrapServersP, String topicP) {
        Properties props= new Properties();
        bootstrapServersP=bootstrapServers;
        topicP=topic;
        try {

            props.setProperty("bootstrap-servers", bootstrapServers);
            props.setProperty("topic", topic);


            logger.info("Se ha completado la lectura del fichero de configuracion del config-server ControllerFPC.setProperties" );
            }catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                //myLog.escribir(m1.toString()+"Exception: Error en metodo ServletFPC.crearConsulta no se ha enviado la request correctamente "+e.getMessage());
                logger.error("Exception: ControllerFPC.setPropiedades ha fallado la lectura del fichero de configruacion colgado en el config server  " + e.getMessage());
            }


        return props;
    }

    public String callfindById(
               String appians, Properties porpA) {//@PathVariable long id
                ; 
                String resultborrar="callfindById";
                try {
                    String topico=topic;
                    ControllerFPC con= new ControllerFPC();

                    String answer = appians.substring(appians.indexOf(":")+1,appians.indexOf(","));
                    System.out.println(" has entrado en post recibir"+appians+ " extraccion --> "+answer);
                    ServletFPC srv = new ServletFPC();
                    resultborrar=srv.borrarReg(answer,servletContext, propertiesName, logger, porpA);

                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    System.out.println(e.getMessage());
                    logger.error("Exception : ControllerFPC.calculateLoadVal en la lectura del fichero de propiedades  " + e.getMessage());
                    resultborrar="Exception : ControllerFPC.calculateLoadVal en la lectura del fichero de propiedades  " + e.getMessage();
                }


                return "exito"+resultborrar;
            }

}


我实际上在我的应用程序中得到了什么:`

2019-03-29 10:54:16.506  INFO 26296 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3688eb5b: startup date [Fri Mar 29 10:54:16 CET 2019]; root of context hierarchy
2019-03-29 10:54:16.696  INFO 26296 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-29 10:54:16.727  INFO 26296 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7738e7d1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.6.RELEASE)

2019-03-29 10:54:21 INFO  ControllerFPC:516 - Starter of APP  
 Finnish starting process 

如您所见,我的应用程序没有进一步发展,我对此感到担心。

我期望的是这样的:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.5.RELEASE)

2019-03-29 10:46:26.662  INFO 7124 --- [           main] com.demo.SpringBootWithKafkaApplication  : Starting SpringBootWithKafkaApplication on ESX5CD8051MG5 with PID 7124 (C:\Users\llacadena\git\spring-boot-kafka\target\classes started by llacadena in C:\Users\llacadena\git\spring-boot-kafka)
2019-03-29 10:46:26.664  INFO 7124 --- [           main] com.demo.SpringBootWithKafkaApplication  : No active profile set, falling back to default profiles: default
2019-03-29 10:46:26.692  INFO 7124 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3d680b5a: startup date [Fri Mar 29 10:46:26 CET 2019]; root of context hierarchy
2019-03-29 10:46:27.191  INFO 7124 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.kafka.annotation.KafkaBootstrapConfiguration' of type [org.springframework.kafka.annotation.KafkaBootstrapConfiguration$$EnhancerBySpringCGLIB$$b4a0ee3c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-29 10:46:27.441  INFO 7124 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9000 (http)
2019-03-29 10:46:27.453  INFO 7124 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-29 10:46:27.454  INFO 7124 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
2019-03-29 10:46:27.457  INFO 7124 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_161\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;%JAVA_HOME\bin%;C:\opt\apache-maven-3.6.0\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Webex\Webex\Applications;C:\Users\llacadena\AppData\Local\Microsoft\WindowsApps;C:\Users\llacadena\AppData\Local\atom\bin;C:\Users\llacadena\AppData\Local\Programs\Fiddler;C:\Users\llacadena\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\llacadena\AppData\Local\Programs\Git\cmd;C:\Program Files\Java\jre1.8.0_181\bin;C:\bin\zookeper\zookeeper-3.4.13\bin;;.]
2019-03-29 10:46:27.513  INFO 7124 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-29 10:46:27.513  INFO 7124 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 823 ms
2019-03-29 10:46:27.553  INFO 7124 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-03-29 10:46:27.555  INFO 7124 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-29 10:46:27.556  INFO 7124 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-29 10:46:27.556  INFO 7124 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-29 10:46:27.556  INFO 7124 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-29 10:46:27.668  INFO 7124 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 10:46:27.774  INFO 7124 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3d680b5a: startup date [Fri Mar 29 10:46:26 CET 2019]; root of context hierarchy
2019-03-29 10:46:27.806  INFO 7124 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/kafka/publish],methods=[POST]}" onto public void com.demo.controllers.KafkaController.sendMessageToKafkaTopic(java.lang.String)
2019-03-29 10:46:27.808  INFO 7124 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-29 10:46:27.809  INFO 7124 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-29 10:46:27.824  INFO 7124 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 10:46:27.824  INFO 7124 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 10:46:27.955  INFO 7124 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-29 10:46:27.971  INFO 7124 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483547
2019-03-29 10:46:27.982  INFO 7124 --- [           main] o.a.k.clients.consumer.ConsumerConfig    : ConsumerConfig values: 
    auto.commit.interval.ms = 5000
2019-03-29 10:46:28.018  INFO 7124 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 1.0.2
2019-03-29 10:46:28.018  INFO 7124 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : 2a121f7b1d402825
2019-03-29 10:46:28.021  INFO 7124 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 
2019-03-29 10:46:28.041  INFO 7124 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9000 (http) with context path ''
2019-03-29 10:46:28.044  INFO 7124 --- [           main] com.demo.SpringBootWithKafkaApplication  : Started SpringBootWithKafkaApplication in 1.621 seconds (JVM running for 2.053)

- - - 更新。 - - -


我注意到这是在我从远程配置服务器读取 applitcation.yml 文件的配置之后开始的。所以我查看了我的 bootstrap.properties 文件发生了什么。

spring.application.name=kafkaclient

ribbon.eureka.enabled=false

 this is the default
spring.cloud.config.profile=dev
spring.cloud.config.uri=http://config-service-remote.domain.corp

如果我评论声明配置服务器(spring.cloud.config.uri)和配置文件(spring.cloud.config.profile)的行,应用程序将继续部署。但问题是我需要从该配置服务器中读取,所以有什么想法为什么会发生这种情况?

----更新2 -----

正如 deadpool 推荐的那样,我开始了一个没有 ControllerFPC 类的新项目,并创建了一个只启动应用程序的新主类。我在这个来源(https://www.confluent.io/blog/apache-kafka-spring-boot-application)中启发了自己,但仍然遇到同样的问题。当我声明引导变量 (spring.cloud.config.uri= http://config-service-remote.domain.corp ) 我的应用程序没有完成部署。

- - - 解决方案 - -

信不信由你,这个问题与配置服务器或我之前所说的无关。我的问题是我的applications.yml,这个错误非常愚蠢但也非常令人困惑,因为它没有任何意义。问题是,如果你使用制表符来保持结构,你最终会导致文件崩溃,所以什么都不会起作用,当然你不会理解,最后你会感到沮丧。最好使用空格键制表,这听起来很傻,但对我有用。好吧,我向您展示了一个很好的例子来说明问题所在


spring:
  kafka:
    consumer:
      group-id: foo <-- my problem was here because I tabulate this line. 
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer

app:
  topic:
    foo: foo.t

logging:
  level:
    root: WARN
    org.springframework.web: INFO
    com.memorynotfound: DEBUG

````````````````````````````````````

标签: javaspringspring-bootkafka-consumer-api

解决方案


推荐阅读