标签: overwrite

如何使用注释仅按名称覆盖Spring服务bean

鉴于我将Spring bean配置为

@Service("myService")
public class DefaultService extends MyService {
}
Run Code Online (Sandbox Code Playgroud)

和一个使用这个bean的类

public class Consumer {
    @Autowired
    @Qualifier("myService")
    private MyService service;
    ...
}
Run Code Online (Sandbox Code Playgroud)

我现在希望我的项目(包括前面的类)有Consumer另一个MyService被注入的实现.因此我想覆盖beanmyService

@Service("myService")
public class SpecializedService implements MyService {
}
Run Code Online (Sandbox Code Playgroud)

导致Consumer现在携带一个SpecializedService而不是DefaultService.根据定义,我不能在Spring容器中有两个具有相同名称的bean.我怎么能告诉spring,新服务的定义是否会覆盖旧服务?我不想修改这个Consumer类.

spring inject overwrite javabeans autowired

7
推荐指数
1
解决办法
3万
查看次数

在codeigniter中上传图像时覆盖以前的文件

我在codeigniter中上传图片,效果很好.但是当我尝试更新图像时,codeigniter会在每个图像的末尾自动添加1.这将在我的images目录中添加未使用的图像.如何覆盖现有图像而不是为其命名并保存?

php codeigniter image overwrite

7
推荐指数
1
解决办法
2万
查看次数

geom_text在所有方面写入所有数据

我使用ggplot和facet_grid,我想在每个方面指出每个方面的观察数量.我按照许多网站上提供的示例进行操作,但是当我将其写入任何内容时,它会在所有四个图上将所有四个观察数字叠加在一起.

这里是geom_text图层命令:geom_text(data = ldata,aes(x = xpos,y = ypos,label = lab,size = 1),group = NULL,hjust = 0,parse = FALSE)

和ldata是一个数据框,列出了每个图上的坐标(xpos,ypos)和观察数(实验室).它在图上的正确位置打印数字,但所有四个都在所有四个图上相互重叠.我无法弄清楚我做错了什么.

LDATA:

xpos ypos实验室

1 10 1.35 378

2 10 1.35 2

3 10 1.35 50

4 10 1.35 26

r overwrite ggplot2 facets

7
推荐指数
1
解决办法
2981
查看次数

Visual Studio永久禁用覆盖

我对Visual Studio有一点小麻烦.在Visual Studio的右下角,有一个INS/OVR按钮可以切换插入/覆盖.我总是将此按钮设置为INS,我总是希望将其设置为INS.

但是,有时当我构建解决方案时,Visual Studio会将其更改回OVR.我必须单击按钮将其更改回INS,这有点不方便.

我不知道为什么这个设置有时会改变.无论如何我可以永久禁用Visual Studio中的覆盖模式或阻止解决方案构建更改此设置吗?

insert overwrite visual-studio

7
推荐指数
2
解决办法
6654
查看次数

覆盖服务器上的文件(PHP)

我正在制作一个Android应用程序,需要能够将文件推送到服务器上.

为此,我正在使用POST,fopen/fwrite但此方法仅附加到文件并unlink在写入文件之前使用无效.(file_put_contents具有完全相同的效果)

这就是我到目前为止所拥有的

<?php
$fileContent = $_POST['filecontent'];

$relativePath = "/DatabaseFiles/SavedToDoLists/".$_POST['filename'];
$savePath = $_SERVER["DOCUMENT_ROOT"].$relativePath; 

unlink($savePath);

$file = fopen($savePath,"w");
fwrite($file,$fileContent);
fclose($file);

?>
Run Code Online (Sandbox Code Playgroud)

当我不尝试写入文件时,该文件将正确删除它自己,但如果我尝试写入它,它将附加.

有人有任何关于覆盖文件内容的建议吗?

谢谢,卢克.

php fopen overwrite fwrite unlink

6
推荐指数
2
解决办法
2万
查看次数

对重载函数'pow'的模糊调用

我在运行以下代码时遇到了一些问题.我得到了这个:错误C2668:'pow':对重载函数的模糊调用.我试图使用static_cast手动将参数转换为适当的类型,但是我想我得到一些指针错误?!

该程序应将数字从基数16转换为基数10.

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>

//base 16 to base 10

int convert(char *n){
    int result = 0;
    for (int i = strlen(n) - 1; i >= 0; i--){
        if (n[i] >= 'a')
            result += (n[i] - 'a' + 10)* pow(16, strlen(n) - i - 1);
        else
        if (n[i] >= 'A')
            result += (n[i] - 'A' + 10)* pow(16, strlen(n) - i - 1);
        else
        if (n[i] >= '0')
            result += (n[i] …
Run Code Online (Sandbox Code Playgroud)

c++ function overwrite pow

6
推荐指数
1
解决办法
2万
查看次数

如何覆盖现有的Java文件

我想覆盖之前保存的文件,我的SaveAs代码:

public void SaveAs(){
            judul = jTextJudul.getText();
            s = area.getText();
            if(s.length()>0){//jika s terisi
                try { 
                    dialog = new FileDialog(this,"Save File As",FileDialog.SAVE);
                    dialog.setFile(judul+".txt");
                    dialog.setVisible(true);
                    path=dialog.getDirectory()+dialog.getFile();
                    FileOutputStream fos=new FileOutputStream(path);
                    System.out.println(s);
                    byte[] b=s.getBytes();
                    fos.write(b);
                    fos.close();
                    setTitle(name);
                }
                catch(Exception e){
                    JOptionPane.showMessageDialog(this,e.getMessage());
                }
            }
            else{
                JOptionPane.showMessageDialog(this,"Apa anda yakin menyimpan file kosong?");
            }
        }
Run Code Online (Sandbox Code Playgroud)

而我的保存代码(必须覆盖存在的文件)

public void Save(){
        dialog = new FileDialog(this,"Save",FileDialog.SAVE);
        file = new File(path+".txt");
        s = area.getText();
          try{
            // Create file 
            FileWriter fstream = new FileWriter(file,true);
            BufferedWriter out = new BufferedWriter(fstream);
            out.write(s);
            //Close the …
Run Code Online (Sandbox Code Playgroud)

java filedialog awt overwrite save

6
推荐指数
1
解决办法
4万
查看次数

Python:将数组定义为实例类属性

我需要有几个对象,每个对象都有一个单独的数组。我写了这段代码:

    read_values = list()
    for read_unit in read_units:
        read_value = ReadValues.objects.all().filter(ReadID=read_unit.ReadID)

        element = TempObjectForReadValues()
        for read_element in read_value:
            element.read_elements[read_element.Code] = read_element.ReadValue
        read_values.append(element)
        print(element.read_elements)

    print('  ')
    for test_element in read_values:
        print(test_element.read_elements)
Run Code Online (Sandbox Code Playgroud)

这就是我定义该类的方式:

    class TempObjectForReadValues():
        read_elements = [None] * 10
Run Code Online (Sandbox Code Playgroud)

结果是:

[None, None, 16.0, None, 189.0, 345.0, None, None, None, None]
[None, None, 16.0, 43.0, 876.0, 345.0, None, None, None, None]

[None, None, 16.0, 43.0, 876.0, 345.0, None, None, None, None]
[None, None, 16.0, 43.0, 876.0, 345.0, None, None, None, None]
Run Code Online (Sandbox Code Playgroud)

这意味着数据将被覆盖以前的数据。另外,如果我不向新对象中的数组分配任何内容,它会保存前一个对象的结果。:( …

arrays attributes class overwrite python-3.x

6
推荐指数
1
解决办法
2万
查看次数

为什么我可以在 JavaScript 中定义两次相同的函数?

我有一个 javascript 文件,在其中编写了一堆 jquery 函数。我有一个返回角度范围的函数。我发现如果我将同一个函数编写两次,代码仍然会执行。

function getngScope()
{
    alert(2);
    return angular.element($('#data-area')).scope();
}

function getngScope()
{
    alert(1);
    return angular.element($('#data-area')).scope();
}
Run Code Online (Sandbox Code Playgroud)

当我打电话时,getngScope()我收到“1”警报并返回范围。为什么它有这种行为?

javascript function overwrite

6
推荐指数
2
解决办法
5255
查看次数

如何使用镶木地板读取和写入火花中的同一个文件?

我试图从 spark 中的镶木地板文件中读取,与另一个 rdd 进行联合,然后将结果写入我读取的同一个文件中(基本上是覆盖),这会引发以下错误:

 couldnt write parquet to file: An error occurred while calling o102.parquet.
: org.apache.spark.sql.catalyst.errors.package$TreeNodeException: execute, tree:
TungstenExchange hashpartitioning(billID#42,200), None
+- Union
   :- Scan ParquetRelation[units#35,price#36,priceSold#37,orderingTime#38,itemID#39,storeID#40,customerID#41,billID#42,sourceRef#43] InputPaths: hdfs://master-wat:8020/user/root/dataFile/parquet/general/NPM61LKK1C/Billbody
   +- Project [units#22,price#23,priceSold#24,orderingTime#25,itemID#26,storeID#27,customerID#28,billID#29,2 AS sourceRef#30]
      +- Scan ExistingRDD[units#22,price#23,priceSold#24,orderingTime#25,itemID#26,storeID#27,customerID#28,billID#29] 

    at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:49)
    at org.apache.spark.sql.execution.Exchange.doExecute(Exchange.scala:247)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
    at org.apache.spark.sql.execution.Sort.doExecute(Sort.scala:64)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
    at org.apache.spark.sql.execution.Window.doExecute(Window.scala:245)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
    at org.apache.spark.sql.execution.Filter.doExecute(basicOperators.scala:70)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130) …
Run Code Online (Sandbox Code Playgroud)

overwrite apache-spark parquet

6
推荐指数
3
解决办法
7337
查看次数