Intellij Idea 如何在IntelliJ中更改代码生成设置?

nkcskrwz  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(145)

我在一个对象中有以下变量:

private String mName;
private String mArtist;
private String mWhosampledPage;
private String mImage;
private List<Pair<String, String>> mSamples;
private List<Pair<String, String>> mSampledIn;
private List<Pair<String, String>> mCovers;
private List<Pair<String, String>> mRemixes;

我想在IntelliJ中使用Alt+Insert来自动生成一个构造函数,当我这样做时,这就是生成的内容:

public Song(String mName, String mArtist, String mWhosampledPage, String mImage, List<Pair<String, String>> mSamples, List<Pair<String, String>> mSampledIn, List<Pair<String, String>> mCovers, List<Pair<String, String>> mRemixes) {
    this.mName = mName;
    this.mArtist = mArtist;
    this.mWhosampledPage = mWhosampledPage;
    this.mImage = mImage;
    this.mSamples = mSamples;
    this.mSampledIn = mSampledIn;
    this.mCovers = mCovers;
    this.mRemixes = mRemixes;
}

如何更改生成设置,使创建的构造函数更像这样:

public Song(String name, String artist, String whosampledPage, String image, List<Pair<String, String>> samples, List<Pair<String, String>> sampledIn, List<Pair<String, String>> covers, List<Pair<String, String>> remixes) {
    mName = name;
    mArtist = artist;
    mWhosampledPage = whosampledPage;
    mImage = image;
    mSamples = samples;
    mSampledIn = sampledIn;
    mCovers = covers;
    mRemixes = remixes;
}

我知道这是可能的,因为我已经在其他IntelliJ配置(不同的设备)中使用了它,但我不确定如何进行切换。
谢谢你

lf3rwulv

lf3rwulv1#

转到设置Preferences | Editor | Code Style | Java,并在选项卡Code Generation下将字段名称前缀设置为m

相关问题