简体   繁体   English

热交换代理,添加新类

[英]Hotswap Agent, add New Classes

can I add new class on Hotswap Agent? 我可以在Hotswap Agent上添加新的课程吗? I try changing name methods, body of methods, fields, and works fine, but when I add new class and call it on another the app crash, don do the content of that class and not show errors. 我尝试更改名称方法,方法主体,字段,并且工作正常,但是当我添加新类并在另一个应用程序崩溃时调用它时,请不要执行该类的内容并且不会显示错误。

package test;

public class TestNewClass 
{
        public void test()
    {
        System.out.println("test new class");
    }
}



@Controller
public class MenuController extends MainController
{
    @RequestMapping(value = "/menu/getMenu", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE_UTF_8)
        @ResponseBody
        public String getMenu(HttpServletResponse httpRessponse)
        {
            System.out.println("test 3 "+test);
            UserVitrina user = getUserVitrina();
            MenuHandler menuHandler = new MenuHandler();
            try
            {
                genericBO.openSessionTransaction();
                Map menu = menuHandler.getMenu(user.getIdUsuario());
                genericBO.commitTransaction();
                return new Gson().toJson(menu);
            }
            catch (Exception ex)
            {
                new Log().printLogError("MENU. Error obtener menu.", ex, (user == null ? "usuario nulo" : user.getUsername()), null, Resources.LogName.DEBUG);
                httpRessponse.setStatus(HttpStatus.BAD_GATEWAY.value());
                genericBO.abortTransaction();
                return new Gson().toJson(new MessageServer().generateMessageError(ex));
            }
            finally
            {
                genericBO.closeSession();
            }
        }
}

If you do hotswap with your IDE, it swaps only existing classes. 如果使用IDE进行热交换,它将仅交换现有的类。 New classes are loaded by standard mechanism from the classpath. 通过标准机制从类路径中加载新类。 Is your new class on the classpath? 您的新课程在课程路径上吗? If you have eg multimodule maven project, you may be able to swap classes from dependent module, but new classes are loaded only from built jar files. 如果您有例如multimodule maven项目,则可以从依赖模块交换类,但是新类仅从内置的jar文件中加载。

To solve this add extraClaspath ( http://hotswapagent.org/mydoc_configuration.html ) to your hotswap-agent.properties file. 要解决此问题,请将extraClaspath( http://hotswapagent.org/mydoc_configuration.html )添加到hotswap-agent.properties文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM