簡體   English   中英

Spring-Boot BeanCreatingException

[英]Spring-Boot BeanCreatingException

我的項目正在運行,但 5 分鍾后沒有任何變化,我重新編譯我的項目時出現錯誤,只需在此處輸入代碼即可。

2018-11-12 14:04:27.508  INFO 7904 --- [           main] c.i.IwbEmuhasebeAdapterApplication       : Starting IwbEmuhasebeAdapterApplication on PRMS-ALC with PID 7904 (D:\eclipse-workspace\iwb-emuhasebe-adapter\target\classes started by Alican in D:\eclipse-workspace\iwb-emuhasebe-adapter)
2018-11-12 14:04:27.516  INFO 7904 --- [           main] c.i.IwbEmuhasebeAdapterApplication       : No active profile set, falling back to default profiles: default
2018-11-12 14:04:27.626  INFO 7904 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5a45133e: startup date [Mon Nov 12 14:04:27 EET 2018]; root of context hierarchy
2018-11-12 14:04:30.873  INFO 7904 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8083 (http)
2018-11-12 14:04:30.940  INFO 7904 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-11-12 14:04:30.940  INFO 7904 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
2018-11-12 14:04:30.969  INFO 7904 --- [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_171\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.8.0_171\jre\bin;C:/Program Files/Java/jre1.8.0_191/bin/server;C:/Program Files/Java/jre1.8.0_191/bin;C:/Program Files/Java/jre1.8.0_191/lib/amd64;C:\oracle\product\11.2.0\dbhome_1\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\;C:\Windows\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_171;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\MongoDB\Server\3.6\bin;C:\Program Files\PuTTY\;C:\Program Files\Java\jdk1.8.0_171\bin\;C:\Program Files\Java\jre1.8.0_191\bin;C:\Users\Alican\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Alican\AppData\Roaming\npm;C:\eclipse;;.]
2018-11-12 14:04:31.212  INFO 7904 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-11-12 14:04:31.213  INFO 7904 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3599 ms
2018-11-12 14:04:31.354  INFO 7904 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-11-12 14:04:31.359  INFO 7904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-12 14:04:31.360  INFO 7904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-12 14:04:31.360  INFO 7904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-11-12 14:04:31.360  INFO 7904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-12 14:04:31.800  WARN 7904 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appServlet': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.iworkbetter.controller.AppServlet] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
2018-11-12 14:04:31.804  INFO 7904 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

這是我的 appServlet.java

@RestController
public class AppServlet {
    @Autowired
    private AdapterEngine engine;

    public AppServlet(AdapterEngine engine) {
        this.engine = engine;
    }

    @RequestMapping("/EFaturaSender")
    public void hndEFaturaSender(HttpServletRequest request, HttpServletResponse response) {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        response.setContentType("text/html; charset=UTF-8");
        engine.eFaturaSender(customizationId, AdapterUtil.uInt(requestParams.get("efatura_id")));
    }

    /*
     * @RequestMapping("/EFaturaReceiverGelen") public void
     * hndEFaturaReceiverGelen(HttpServletRequest request, HttpServletResponse
     * response) throws IOException { Map<String, String> requestParams =
     * AdapterUtil.getParameterMap(request); int customizationId = 0;
     * 
     * if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) { try {
     * customizationId = AdapterUtil.uInt(requestParams.get("customizationId")); }
     * catch (Exception e) { e.printStackTrace(); } } int insertedInvoice = 0;
     * response.setContentType("text/html; charset=UTF-8"); insertedInvoice =
     * engine.eFaturaGelenAra(customizationId,
     * AdapterUtil.uDate(requestParams.get("start_dt")),
     * AdapterUtil.uDate(requestParams.get("end_dt")));
     * response.getWriter().write("{'success':true,'insertedInvoice':" +
     * insertedInvoice + "}");
     * 
     * }
     */

    @RequestMapping("/EFaturaReceiverGiden") // TODO Şimdilik gerek yok
    public void hndEFaturaReceiverGiden(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        int insertedInvoice = 0;
        response.setContentType("text/html; charset=UTF-8");
        try {
            insertedInvoice = engine.eFaturaAlGiden(customizationId, requestParams);
            response.getWriter().write("{'success':true,'insertedInvoice':" + insertedInvoice + "}");
        } catch (Exception e) {
            response.getWriter().write("{'success':false}");
            e.printStackTrace();
        } finally {
            response.getWriter().close();
        }
    }

    @RequestMapping("/EFaturaMukellefGuncelle") // TODO
    public void hndEFaturaMukellefGuncelle(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;
        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        int insertedMukellef = 0;
        response.setContentType("text/html; charset=UTF-8");
        try {
            insertedMukellef = engine.eFaturaMukellefGuncelle(customizationId);
            response.getWriter().write("{'success':true,'insertedMukellef':" + insertedMukellef + "}");
        } catch (IOException e) {
            response.getWriter().write("{'success':false}");
            e.printStackTrace();
        } finally {
            response.getWriter().close();
        }
    }

    @RequestMapping("/EFaturaGelenFaturaDurum")
    public void hndGelenEFaturaDurumGuncelle(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        response.setContentType("text/html; charset=UTF-8");
        try {
            engine.eFaturaGelenDurumSorgula(customizationId, AdapterUtil.uInt(requestParams.get("efatura_id")));
            response.getWriter().write("{'success':true}");
        } catch (Exception e) {
            response.getWriter().write("{'success':false}");
            e.printStackTrace();
        } finally {
            response.getWriter().close();
        }
    }

    @RequestMapping("/EFaturaGidenFaturaDurum")
    public void hndGidenEFaturaDurumGuncelle(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        response.setContentType("text/html; charset=UTF-8");
        try {
            engine.eFaturaGidenFaturaDurumSorgula(customizationId, AdapterUtil.uInt(requestParams.get("efatura_id")));
            response.getWriter().write("{'success':true}");
        } catch (Exception e) {
            response.getWriter().write("{'success':false}");
            e.printStackTrace();
        } finally {
            response.getWriter().close();
        }
    }

    @RequestMapping("/EFaturaYanıtla")
    public void hndEFaturaYanitla(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        response.setContentType("text/html; charset=UTF-8");
        try {
            engine.eFaturaYanitla(customizationId, requestParams);
            response.getWriter().write("{'success':true}");
        } catch (Exception e) {
            response.getWriter().write("{'success':false}");
            e.printStackTrace();
        } finally {
            response.getWriter().close();
        }
    }

    // @Scheduled(fixedRate = 200000) // gelen fatura icin scheduled
    public void scheduled4ReceiverInvoice() {
        int customizationId = 0;// TODO
        Date end_date = new Date();
        GregorianCalendar start_date = new GregorianCalendar();
        start_date.setTime(end_date);
        start_date.add(Calendar.DATE, -6);// bugunle 6 gun oncesi
        engine.eFaturaGelenAra(customizationId, start_date.getTime(), end_date);

    }

    // @Scheduled(fixedRate = 200000)
    public void scheduled4MukellefUpdate() {
        int customizationId = 0;
        engine.eFaturaMukellefGuncelle(customizationId);
    }

    @RequestMapping("EFaturaReceiverGelen")
    public void deserializeTest(HttpServletRequest request, HttpServletResponse response)
            throws JAXBException, IOException {
        Map<String, String> requestParams = AdapterUtil.getParameterMap(request);
        int customizationId = 0;

        if (!AdapterUtil.isEmpty(requestParams.get("customizationId"))) {
            try {
                customizationId = AdapterUtil.uInt(requestParams.get("customizationId"));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        int insertedInvoice = 0;
        response.setContentType("text/html; charset=UTF-8");
        insertedInvoice = engine.deserializeTest(customizationId, AdapterUtil.uDate(requestParams.get("start_dt")),
                AdapterUtil.uDate(requestParams.get("end_dt")));
        response.getWriter().write("{'success':true,'insertedInvoice':" + insertedInvoice + "}");

    }

    @RequestMapping("ShowInvoice")
    public void showInvoiceOnBrowser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        byte[] pdfBytes = engine.showInvoice();

        JSONObject j = new JSONObject();
        try {
            j.put("data1", pdfBytes);
        } catch (JSONException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }
        // response.setContentType("application/json");
        PrintWriter out = response.getWriter();
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        out.print(j);
        out.flush();

        try {
            response.getWriter().write("{'success':true,'data':" + "}");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        /*
         * response.setHeader("Content-Type", "text/plain");
         * response.setHeader("success", "yes"); PrintWriter writer =
         * response.getWriter(); writer.write(pdfBytes.toString()); writer.close();
         */
    }

}

這是警告信息:

2018-11-12 14:54:13.580 WARN 7784 --- [main] ConfigServletWebServerApplicationContext:上下文初始化期間遇到異常 - 取消刷新嘗試:org.springframework.beans.factory.BeanCreationException:創建名為“appServlet”的 bean 時出錯:Lookup方法解析失敗; 嵌套異常是 java.lang.IllegalStateException: Failed to introspect Class [com.iworkbetter.controller.AppServlet] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

我有同樣的問題。 我已經修復了兩件事,問題解決了:

  • 我發現我在 pom.xml 中打錯了字。

  • 我使用 Java 8 運行,但使用 Java 11 編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM