如何将beans.xml添加到tomcat上下文

时间:2019-05-19 14:36:27

标签: java tomcat java-8 tomcat8

我添加了带有tomcat上下文的web.xml配置文件,如下所示。似乎以此配置开始的tomcat实例无法识别bean.xml文件,因为我不能使用@Inject注释。问题是,我如何使tomcat识别beans.xml文件。谢谢。

    Tomcat tomcat = new Tomcat();
    tomcat.setPort(Integer.valueOf(webPort));
    Context context = tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
    File configFile = new File(webappDirLocation + "WEB- INF/web.xml");
    context.setConfigFile(configFile.toURI().toURL());
    tomcat.start();
    tomcat.getServer().await();

0 个答案:

没有答案