java代码生成补丁 java代码自动生成工具

如何将java源代码打包生成jar?工具:
eclipse
方法:
1、启动eclipse;
2、在eclipse中建立好工程与类并写好代码;
3、点击“File-Export”;
4、在弹击的界面中选择“Java-JAR file” , 再点击“Next”;
5、选择要打包的文件,再点击“Browse”;
6、在弹出的界面中选择好打包后的文件的存放路径 , 再输入文件名,最后点击“保存”;
7、点击“Finish”;
8、打包成功 。
java大神来看看,怎么给java web项目打patch(补丁).java文件在本地编译后 , 在target WEB-INF下找到对应的.class文件,然后替换容器中对应的.class文件,再重启tomcat就好了
如何抑制Java的警告,特定目录或文件,如生成的代码1. 从版本3.8 M6开始,Eclipse的(准确的说:JDT的)有内置的函数,这 。它是可配置的,通过一个项目的构建路径:项目属性 Java构建路径编译器来源 在这里宣布:Eclipse的3.8和4.2的M6-新的和值得注意的是,所谓的选择性忽略源文件夹中的错误/警告 。这也是那里的截图是从 。这是链接错误220928开发新的函数 。
2. 有这个一票,臭虫220928,具有自为Eclipse 3.8 。请参考这个答案的细节 。上创建(或至少指向)一个名为“warningcleaner”在35插件票“马克”:如果你坚持使用Eclipse 3.7或更低 。我认为有很多在等待这个函数被集成到Eclipse中 。这真的很简单: 安装插件 。右键单击项目并选择“添加/删除生成的代码自然” 。打开项目设置(右键单击并选择“属性”) 。打开选项卡“警告清洁' 。选择您想从忽略警告的源文件夹 。
3. 我解决了这个maven的正则表达式替换插件-它并没有解决 CodeGo.net , 但治愈的痛苦:plugin
groupIdcom.google.code.maven-replacer-plugin/groupId
artifactIdmaven-replacer-plugin/artifactId
version1.3.2/version
executions
execution
phaseprepare-package/phase
goals
goalreplace/goal
/goals
/execution
/executions
configuration
includes
includetarget/generated-sources/antlr/**/*.java/include
/includes
regextrue/regex
regexFlags
regexFlagMULTILINE/regexFlag
/regexFlags
replacements
replacement
token^public class/token
value@SuppressWarnings("all") public class/value
/replacement
/replacements
/configuration
/plugin
请注意,我没能拿到**符号来工作,所以你可能需要准确地指定路径 。参见下面的如何不产生重复@SupressWarnings
4. 我认为最好的你能做的就是使项目的具体设置用于显示警告 。窗口-设定- Java的-编译器-错误/警告 在窗体的顶部是一个链接,用于配置项目的具体设置 。
5. 网友@乔恩暗示ant代码来做到这一点 。下面是我的echoAdding @SuppressWarnings("all") to ANTLR generated parser/lexer *.java/echo
echo in ${project.build.directory}/generated-sources/antlr//echo
replace dir="${project.build.directory}/generated-sources/antlr/"
summary="true"
includes="**/*.java"
token="public class"
value='https://www.04ip.com/post/@SuppressWarnings("all") public class' /
需要注意的是Ant的Replace中并没有文本的正则表达式 所以它的令牌相匹配行的开始如maven的正则表达式替换插件一样 。我跑了Antlr从Maven的antrun-插件在我的Maven POM,ANTLR的maven插件没有用的Cobertura Maven插件踢好我这样做的 。(我知道这不是一个答案 , 原来的问题,但我不能在一个格式化的Ant代码到另一个答案,只在一个答案)
6. 我不认为Eclipse的本质提供了一种在目录级做到这一点(但我不知道) 。你可以有生成的文件去到一个单独的Java项目,并控制该特定项目的警告 。我一般喜欢把自动生成的代码在一个单独的项目呢 。
7. 您只能抑制警告在项目级别 。但是,您可以配置你的问题选项卡从文件或软件包抑制警告 。进入配置 , 并与“关于工作组:”工作范围 。
8. 我做这几个ANTLR的语法,它生成一个Javaant 。Ant构建脚本添加@SuppressWarnings("all")一个Java文件,并@Override到另一个 。我可以看看它是如何准确地做,如果你有兴趣 。
9. 在ANTLR 2的情况下,有可能通过appenidng抑制在生成的代码中的警告@SuppressWarnings在类声明中的语法文件之前,例如:{@SuppressWarnings("all")} class MyBaseParser extends Parser;
10. 这可以通过从构建路径中排除特定的目录来完成(下面的例子就是Eclipse 3.5) [1]调出Java构建路径 点击projectin包资源管理器 右击,属性 选择Java Build Path [2]将目录添加到排除 来源标签应包含项目源文件夹的详细信息 展开源文件夹 , 并找到了“排除:'属性 选择“排除:”,然后单击编辑 添加文件夹到添加/添加多个选项 单击Finish(完成),然后确定为Eclipse重建 。
11. 该M2E生成这个小python脚本“补丁”.classpath文件并添加所需的XML标记开始与所有的源文件夹target/generated-sources 。你可以从你的项目的根文件夹中运行它 。你需要重新运行它时 , 在Eclipse从M2E重新生成 。和所有风险自负 , ;-)#!/usr/bin/env python
from xml.dom.minidom import parse
import glob
import os
print('Reading .classpath files...')
for root, dirs, files in os.walk('.'):
for name in files:
if (name == '.classpath'):
classpathFile = os.path.join(root, name)
print('Patching file:'classpathFile)
classpathDOM = parse(classpathFile)
classPathEntries = classpathDOM.getElementsByTagName('classpathentry')
for classPathEntry in classPathEntries:
if classPathEntry.attributes["path"].value.startswith('target/generated-sources'):
# ensure that the attributes tag exists
attributesNode = None;
for attributes in classPathEntry.childNodes:
if (attributes.nodeName == 'attributes'):
attributesNode = attributes
if (attributesNode == None):
attributesNode = classpathDOM.createElement('attributes')
classPathEntry.appendChild(attributesNode)
# search if the 'ignore_optional_problems' entry exists
hasBeenSet = 0
for node in attributesNode.childNodes:
if (node.nodeName == 'attribute' and node.getAttribute('name') == 'ignore_optional_problems'):
# it exists, make sure its value is true
node.setAttribute('value','true')
#print(node.getAttribute('name'))
hasBeenSet = 1
if (not(hasBeenSet)):
# it does not exist, add it
x = classpathDOM.createElement("attribute")
x.setAttribute('name','ignore_optional_problems')
x.setAttribute('value','true')
attributesNode.appendChild(x)
try:
f = open(classpathFile, "w")
classpathDOM.writexml(f)
print('Writing file:'classpathFile)
finally:
f.close()
print('Done.')
java项目开发如何自制java打补丁工具看你的应用是什么方式了:
重启的: 直接覆盖就行 。
自动扫描加载的: 覆盖就行
即插即用的: 部署一个就行
【java代码生成补丁 java代码自动生成工具】关于java代码生成补丁和java代码自动生成工具的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读