我想改变使用sun jdk打开jdk的maven java home.我该怎么做 ?
root@ak-EasyNote-TM98:~# mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: tr_TR, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-34-generic", arch: "amd64", family: "unix"
Edit:
Run Code Online (Sandbox Code Playgroud)
非常抱歉.我忘了写下面的代码:
root@ak-EasyNote-TM98:~$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
Run Code Online (Sandbox Code Playgroud)
我的java home默认路径已经是sun jdk了.但maven java home指向openjdk.我想只为maven修复它.
假设我在User结构中有一个密码字段.
type User struct{
UserName string `json:"username"`
Password string `json:"-"`
}
Run Code Online (Sandbox Code Playgroud)
我的客户通过一起发布用户名和密码来注册用户.因此,如果我将JSON解码为上面的结构,它会忽略密码.这是预期的.但是我想知道在编组时是否有任何方法可以忽略字段.我查了官方文档页面但找不到任何东西.
https://golang.org/pkg/encoding/json/
我可以在结构中添加一个额外的字段,但我首先需要知道是否可以使用JSON lib.
我想每小时执行一个方法.我写了一些代码,但这还不足以实现我的目标.下面的代码每60分钟工作一次.
public void Start()
{
System.Threading.Timer timerTemaUserBilgileri = new System.Threading.Timer(new System.Threading.TimerCallback(RunTakip), null, tmrTemaUserBilgileri, 0);
}
public void RunTakip(object temauserID)
{
try
{
string objID = "6143566557387";
EssentialMethod(objID);
TimeSpan span = DateTime.Now.Subtract(lastRunTime);
if (span.Minutes > 60)
{
tmrTemaUserBilgileri = 1 * 1000;
timerTemaUserBilgileri.Change(tmrTemaUserBilgileri, 0);
}
else
{
tmrTemaUserBilgileri = (60 - span.Minutes) * 60 * 1000;
timerTemaUserBilgileri.Change(tmrTemaUserBilgileri, 0);
}
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
}
catch (Exception ex)
{
timerTemaUserBilgileri.Change(30 * 60 * 1000, 0);
Utils.LogYaz(ex.Message.ToString());
}
}
public void EssentialMethod(objec …Run Code Online (Sandbox Code Playgroud) 我已经在 python 上工作了一段时间,然后回到 c# 进行了一个项目。所以我习惯了 python 语言,这迫使我像 python 程序员一样思考,我喜欢这个!
我想问的问题是如何创建一个在其 decarator 之后调用的方法?
Python 装饰器语法:
def p_decorate(func):
def func_wrapper(name):
return "<p>{0}</p>".format(func(name))
return func_wrapper
@p_decorate
def get_text(name):
return "lorem ipsum, {0} dolor sit amet".format(name)
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索但只找到了 .Net Attributes它对我没有帮助。
示例代码,但我想编写自己的 AuthorizationAttribute 类。
public class RestrictAccessToAssignedManagers : AuthorizationAttribute
{
protected override AuthorizationResult IsAuthorized(System.Security.Principal.IPrincipal principal, AuthorizationContext authorizationContext)
{
EmployeePayHistory eph = (EmployeePayHistory)authorizationContext.Instance;
Employee selectedEmployee;
Employee authenticatedUser;
using (AdventureWorksEntities context = new AdventureWorksEntities())
{
selectedEmployee = context.Employees.SingleOrDefault(e => e.EmployeeID == eph.EmployeeID);
authenticatedUser = context.Employees.SingleOrDefault(e => e.LoginID …Run Code Online (Sandbox Code Playgroud) 我经常将文本输出到文件.我想知道:BufferedWriter工作怎么样?
我打电话时是否在文件上写文字writer.write(text)?如果它不写文本,我是否需要使用flush函数来写入数据?
例如:
File file = new File("statistics.txt");
if (!file.exists()) {
file.createNewFile();
}
else
{
file.delete();
file.createNewFile();
}
FileWriter fileWritter = new FileWriter(file.getAbsoluteFile(),true);
BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
Iterator<Map.Entry<String,Token>> it = listofTakenPairMap.entrySet().iterator();
int isim_isim=0;
int isim_fiil=0;
int zarf_fiil=0;
while (it.hasNext()) {
@SuppressWarnings("rawtypes")
Map.Entry pairs = (Map.Entry)it.next();
Token token=(Token)pairs.getValue();
String str=pairs.getKey()+ " = " +token.getCount();
if(token.getTypeOfPairofToken()==0){//isim-isim
isim_isim+=token.getCount();
}
else if(token.getTypeOfPairofToken()==1){
isim_fiil+=token.getCount();
}
else{ //zarf-fiil
zarf_fiil+=token.getCount();
}
System.out.println(str);
bufferWritter.write(str);
bufferWritter.newLine();
//it.remove(); // avoids a ConcurrentModificationException
}
bufferWritter.newLine();
bufferWritter.write("##############################"); …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习python语言及其概念.我写了一些代码来玩多线程.但我注意到多线程和单线程之间没有执行时间差异.
运行脚本的机器有4个核心/线程.
def get_tokens(file_name,map):
print(file_name)
counter = 0
with open(file_name,'r',encoding='utf-8-sig') as f:
for line in f:
item = json.loads(line,encoding='utf-8')
if 'spot' in item and item['sid'] == 4663:
counter+=1
if counter == 500:
break
tokens = nltk.word_tokenize(item['spot'],language='english')
for token in tokens:
if token not in map:
map[token] = 1
else:
map[token] = map[token] + 1;
start_time = time.time()
map = dict();
with ThreadPoolExecutor(max_workers=3) as executor:
for file in FileProcessing.get_files_in_directory('D:\\Raw Data'):
future = executor.submit(FileProcessing.get_tokens, file, map)
end_time = time.time()
print("Elapsed time was …Run Code Online (Sandbox Code Playgroud) 我正在尝试在PHP中运行bash脚本但无法运行它.php -v
PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Run Code Online (Sandbox Code Playgroud)
Ubuntu 12.04 LTS 64位.
我的PHP代码:
$cmd='/www/var/pl/bash.sh';
$retval =-1;
exec( $cmd, $output ); //executing the exec function.
foreach( $output as $tmp )
{
echo "$tmp <br>";
};
Run Code Online (Sandbox Code Playgroud)
bash.sh:
#!/bin/bash
swipl --quiet -s /var/www/pl/ples.pl -g "f(R, gel), writeln(R),open('/var/www/pl/in.txt',write, Stream),
write(Stream, (R)),
nl(Stream),
close(Stream)" -t halt.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我可以在Linux终端上运行bash.sh.
我一直在开发一种微服务,可以在golang中与mysql交互一段时间,我喜欢这种有才华的语言。无论如何有一个问题,不知道问题出在哪里,在我的代码中,在mysql驱动程序中,在mysql中。所以我的机器时区为utc + 3,我正在分享一些结果,可能有帮助
//created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
mysql> select now();
"2016-11-07 22:43:02", //that is correct.
Run Code Online (Sandbox Code Playgroud)
在去
fmt.PrintLn(time.Now().Local())
"2016-11-07 22:51:02" //that is correct too
Run Code Online (Sandbox Code Playgroud)
但是当我将实体添加到数据库中时,mysql工作台向我显示了错误的日期时间。
"2016-11-07 19:51:02" //
Run Code Online (Sandbox Code Playgroud)
转到代码:
func (this *AppLogHandler) addLog(_log *AppLog) (int64, error){
fmt.Println("addLog")
db:= this.Context.DB
stmt, err := db.Prepare("INSERT tbl_logs SET user_id=?,ip_proxy=?, ip_original=?, end_point=?, http_method=?, message=?, status=?, created_date=?")
if(err != nil){
log.Println(err)
return -1, err
}
defer stmt.Close()
res, err := stmt.Exec(&_log.UserID, &_log.IPProxy, &_log.IPOriginal, &_log.Endpoint, &_log.HttpMethod, &_log.Message, &_log.Status, &_log.CreatedDate)
if(err != nil){
log.Println(err)
return -1, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码。
<asp:DataGrid ID="Grid" runat="server" DataKeyField="KeyID" CssClass="grid"
...
<asp:CheckBox runat="server" ID="checkBox-<%#DataBinder.Eval(Container.DataItem,"KeyID")%>" AutoPostBack="false"></asp:CheckBox>
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,出现以下错误:
Error 25 The server tag is not well formed.
Run Code Online (Sandbox Code Playgroud)
注意:这是在没有 runat="server" 的情况下工作的。这个问题的补救措施是什么?
我在互联网上搜索时发现了3d游戏浏览器的webgl和opengl.但我不明白这两种api有什么区别.
我多次尝试将utc datetime转换为本地日期时间,但我失败了.我的utc日期时间格式是
3月8日星期五23:12:27 UTC + 0200 2013
我的JavaScript代码也是
var time = Date(param_time);//param_time is /Date(1362866006646)/
Run Code Online (Sandbox Code Playgroud)
然后时间是太阳3月10日00:21:54 UTC + 0200 2013我需要将datetime作为2008-01-28T20:24:17Z因为我将本地日期时间转换为漂亮的日期时间.
http://ejohn.org/files/pretty.js
我怎样才能做到这一点 ?我在stackoverflow上查看了很多问题,但是没有人能够正常工作.谢谢.
我必须从datatable获得两个字段.然后我应该检查一个."listIDStr"保留不是唯一的userID列表.因此,当我更新行时,我必须使用"作为主键的ID".
List<string> listIDStr = new List<string>();
...
var sqlData = SqlDataBase.SqlGetTable("SELECT ID,UserID FROM TBL_UserT WHERE SID = " + 4663 + " AND UserID = '" + UserID + "'")
.AsEnumerable()
.ToList()
.ConvertAll(x=>x.Field<string>("UserID"))
.ToList();
List<string> Cikan = sqlData.Where(x => !listIDStr.Contains(x)).ToList();
List<string> Eklenen = listIDStr.Where(x => !sqlData.Contains(x)).ToList();
Run Code Online (Sandbox Code Playgroud)
上面的代码是针对一个字段运行的.但是我希望将"ID"与"UserID"一起使用.有没有人知道它是如何做的?