我正在尝试读取这样的 yml 文件。
order:
foo: 5000
bar: 12
Run Code Online (Sandbox Code Playgroud)
我可以用 来阅读它@value。(顺便说一句,我正在使用龙目岛)
@Component
@Data
public class WebConfigProperty {
private Integer foo;
private Integer bar;
public WebConfigProperty(@Value("${order.foo}") @NonNull final Integer foo,
@Value("${order.bar}") @NonNull final Integer bar) {
super();
this.foo = foo;
this.bar = bar;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用,@ConfigurationProperties因为 yml 文件会变得更加复杂。但它不适用于@ConfigurationProperties.
@Component
@ConfigurationProperties("order")
@Data
public class WebConfigProperty {
@NonNull
private Integer foo;
@NonNull
private Integer bar;
}
Run Code Online (Sandbox Code Playgroud)
我还添加@EnableConfigurationProperties了一个配置类。配置中的所有注释都是这样的。
@SpringBootConfiguration
@EnableConfigurationProperties
@EnableAutoConfiguration(exclude = { ... })
@ComponentScan(basePackages = …Run Code Online (Sandbox Code Playgroud) 我有 MKMarkerAnnotationView 来更改地图上图钉的颜色。
func mapView(_ MapView:MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{
let view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "pin")
view.markerTintColor = .blue
return view
}
Run Code Online (Sandbox Code Playgroud)
但是,当我启动我的应用程序时,我的默认位置标记会更改为。如何在不更改此标记的情况下更改引脚?查看位置的代码也很简单
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
self.MapView.showsUserLocation = true
}
Run Code Online (Sandbox Code Playgroud)
感谢您的回答!:)
我使用 swift 和 PDFKit 成功地将突出显示注释添加到 pdf 中,但我无法弄清楚如何让用户再次删除突出显示。
用户可以正常选择文本,然后从 UIMenu 中选择“突出显示”或“删除突出显示”。
为了在选择文本时自定义 pdfView,我更改了显示的菜单 - 首先删除默认操作:
extension PDFView {
override public func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
}
Run Code Online (Sandbox Code Playgroud)
然后在 viewDidLoad() 中我设置了自定义 UIMenuItems:
let menuItem1 = UIMenuItem(title: "Highlight", action: #selector(highlightSelection(_:)))
let menuItem2 = UIMenuItem(title: "Remove highlight", action: #selector(removeHighlightSelection(_:)))
UIMenuController.shared.menuItems = [menuItem1, menuItem2]
Run Code Online (Sandbox Code Playgroud)
选择突出显示时:
@objc func highlightSelection(_ sender: UIMenuItem) {
let selections = pdfViewer.currentSelection?.selectionsByLine()
guard let page = selections?.first?.pages.first else { return }
selections?.forEach({ selection in
let …Run Code Online (Sandbox Code Playgroud) 我正在学习 Spring 和 Hibernate。我准备了图像的实体。这些字段已成功保存到数据库中作为列名,但我需要一些属性存在于实体中但不保存到数据库中。但实际上他们正在被拯救。我尝试删除或使用 @Column 注释,@Column(insertable=false, updatable=false)但没有成功。总是获取数据库中具有空值的列。那么如何防止Spring和Hibernate创建某些字段的列。我正在尝试用字段来做到这一点size,width并且height。
单位代码:
package tk.trzczy.gallery.domain;
import javax.persistence.*;
import java.awt.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@Entity
@Table(name = "images")
public class Image {
@Id
@SequenceGenerator(name = "mySeqGen6", sequenceName = "mySeq6", initialValue = 11, allocationSize = 100)
@GeneratedValue(generator = "mySeqGen6")
private Integer id;
@Column(nullable = false, length = 300)
private String title;
@Column(nullable = false)
private String url;
@Column(insertable=false, updatable=false)
private Long width;
@Column(insertable=false, updatable=false)
private Long height; …Run Code Online (Sandbox Code Playgroud) 我正在使用serde_json板条箱,并且必须为 的返回值进行类型注释serde_json::from_slice()。如果我之后使用 alet和 amatch语句,这有效
let n: Result<serde_json::Value, serde_json::Error> = serde_json::from_slice(buf);
match n {
Ok(_i) => (),
Err(_e) => (),
};
Run Code Online (Sandbox Code Playgroud)
但由于我不需要n,所以我不想let首先做出该声明,并且只使用单个匹配模式。如何为 进行类型注释_i?
目前我正在研究KSP(Kotlin Symbol Processing),我很好奇KSP中的“Symbol”是什么意思。
在与 KAPT 进行比较时,它说“为了运行未经修改的 Java 注释处理器,KAPT 将 Kotlin 代码编译成 Java 存根,保留 Java 注释处理器关心的信息。为了创建这些存根,KAPT 需要解析 Kotlin 程序中的所有符号”。
我不知道“Kotlin程序中的所有符号”到底是什么意思?
将车辆对象持久保存到数据库时会自动生成ID.如何在不坚持的情况下获得ID的价值?
这是代码:
public class Vehicle{
@Id
@GeneratedValue
int id;
private int year;
private String model;
//getters, setters
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
public void updateVehicle(Vehicle vehicle) {
em.getTransaction().begin();
Vehicle vehicleDB = em.find(Vehicle.class, vehicle.getId());
vehicleDB.setYear(vehicle.getYear());
vehicleDB.setModel(vehicle.getModel());
em.getTransaction().commit();
}
Run Code Online (Sandbox Code Playgroud) 我对使用 java 8 很陌生,以前从未真正使用过注释。当我尝试使用 eclipseoxygen、java 8 和指定注释 @FunctionalInterface 为函数式接口编写一个简单的程序时,我看到红色 x(错误)表示函数式接口不是注释类型。
请帮助解决这个问题。我知道提供注释不是强制性的,我的程序在没有注释的情况下也可以正常运行,但我仍然想使用它。
我已经成功安装了 TestNG 并在 eclipse (4.9.0) 中进行了确认。但是,在创建没有主类的基本类时,我在注释 @Test 处收到错误。即使导入测试注释包后,包上也存在错误。并且错误表明无法解决。 在此输入图像描述
我试图将hibernate注释添加到我的Maven项目中,但是我遇到了以下错误:
- ArtifactDescriptorException:无法读取hibernate-commons-annotations的工件描述符:hibernate-commons-annotations:jar:3.0.0.GA:ArtifactResolutionException:无法传输hibernate-commons-annotations:hibernate-commons-annotations:pom:3.0.0来自http:// repository.jboss.com/maven2/的.GA缓存在本地存储库中,在JBoss存储库的更新间隔过去或强制更新之前,不会重新尝试解析.原始错误:无法传输工件hibernate-> commons-annotations:hibernate-commons-annotations:pom:3.0.0.GA from/to JBoss repository(http://repository.jboss.com/maven2/):访问被拒绝> http://repository.jboss.com/maven2/hibernate-commons-annotations/hibernate- commons-annotations/3.0.0.GA/hibernate-commons-annotations-3.0.0.GA.pom.错误>代码403,
- ArtifactDescriptorException:无法读取hibernate-> annotations的工件描述符:hibernate-annotations:jar:3.3.0.GA:ArtifactResolutionException:无法传输hibernate-annotations:hibernate-> annotations:pom:3.3.0.GA from http:/ /repository.jboss.com/maven2/缓存在本地存储库中,在JBoss存储库的更新间隔过去或强制更新之前,不会重新尝试解析.原始错误:无法传输工件hibernate-annotations:hibernate-> annotations:pom:3.3.0.GA from/to JBoss repository(http://repository.jboss.com/ maven2 /):拒绝访问http:// repository.jboss.com/maven2/hibernate- > annotations/hibernate-annotations/3.3.0.GA/hibernate- annotations-3.3.0.GA.pom.错误代码403,禁止
我用这个代码
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.com/maven2/</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
和
<!-- Hibernate annotation -->
<dependency>
<groupId>hibernate-annotations</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.GA</version>
</dependency>
<dependency>
<groupId>hibernate-commons-annotations</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.0.0.GA</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我一直在寻找Java中的注释列表,这些注释具有一些有意义的用途并且默认情况下已启用(无需导入任何内容).例如,@ Deprecated,@ SuppressWarning等我虽然找不到一个.它出在某处,还是我们可以编译一个?