.java-->.class-->run

 /**
 * 生成.java文件和.class文件
 * @param src 一段字符串代码
 * @throws Exception
 */
public static void generateClass(String src) throws Exception{
    String fileDir = System.getProperty("user.dir");
    String fileName = fileDir + "\\src\\com\\waniz\\proxy\\**.java";
    File file = new File(fileName);
    Writer writer = new FileWriter(file);
    writer.write(src);
    writer.close();
    //获取Java编译器
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    //标准文件管理
    StandardJavaFileManager sjfm = compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> iterable = sjfm.getJavaFileObjects(fileName);
    CompilationTask ct = compiler.getTask(null, sjfm, null, null, null, iterable);
    ct.call();
    sjfm.close();
}
/**
 * .class文件载入内存,反射构建对象
 * @return
 * @throws Exception
 */
public static Object loadAndGetInstance() throws Exception{
    URL[] urls = new URL[]{new URL("file:\\" + System.getProperty("user.dir") + "\\src")};
    URLClassLoader classLoader = new URLClassLoader(urls);
    Class<?> c = classLoader.loadClass("com.waniz.proxy.**");

    Constructor<?> contructor = c.getConstructor(Having.class);
    HavingDinnner hd = new HavingDinnner();
    Object obj = contructor.newInstance(hd);
    return obj;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<properties> <hudson.security.AuthorizationMatrixProperty> <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/> <permission>USER:hudson.model.Item.Read:anonymous</permission> </hudson.security.AuthorizationMatrixProperty> <jenkins.model.BuildDiscarderProperty> <strategy class="hudson.tasks.LogRotator"> <daysToKeep>90</daysToKeep> <numToKeep>-1</numToKeep> <artifactDaysToKeep>30</artifactDaysToKeep> <artifactNumToKeep>-1</artifactNumToKeep> </strategy> </jenkins.model.BuildDiscarderProperty> <com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.7.7"> <gitLabConnection>src.ift.run</gitLabConnection> <jobCredentialId/> <useAlternativeCredential>false</useAlternativeCredential> </com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty> <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.34"> <autoRebuild>false</autoRebuild> <rebuildDisabled>false</rebuildDisabled> </com.sonyericsson.rebuild.RebuildSettings> <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.11"> <maxConcurrentPerNode>3</maxConcurrentPerNode> <maxConcurrentTotal>0</maxConcurrentTotal> <categories class="java.util.concurrent.CopyOnWriteArrayList"/> <throttleEnabled>true</throttleEnabled> <throttleOption>project</throttleOption> <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams> <paramsToUseForLimit/> <configVersion>1</configVersion> </hudson.plugins.throttleconcurrents.ThrottleJobProperty> <jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api@2.1071.v1a_188a_562481"> <durationName>hour</durationName> <count>40</count> <userBoost>true</userBoost> </jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl> </properties> 请解释这一段jenkins配置
07-14

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值