我维护大MySQL数据库.我需要每晚备份它,但数据库一直处于活动状态.有来自用户的查询.现在我只是禁用网站,然后进行备份,但这是非常糟糕的,因为服务被禁用,用户不喜欢这样.
如果在备份期间更改数据,备份数据的好方法是什么?
这是什么最佳做法?
我有一个基本上看起来像这样的接口:
public interface ISetting<T> {
public T getDefault();
public T value();
public void set(T value);
public String getName();
public default String getValueName() {
Object obj = value();
if (obj instanceof Boolean) {
return (boolean)obj ? "Yes" : "No";
}
return obj.toString();
}
}
Run Code Online (Sandbox Code Playgroud)
然后在另一个班级我有一个清单 ISetting<?>
private List<ISetting<?>> settings = Arrays.asList(
new ClassMode(),
new EndMode(),
new PlayerLives(),
new JoinMidGame(),
new ScoreboardDisplay(),
new LifePerKill(),
new ExplosiveBullets(),
new ReloadTime());
Run Code Online (Sandbox Code Playgroud)
这一切都完美无缺!但是,我使用我的代码的平台不支持Java 8,所以我必须使用Java 7,这就是问题所在.
如果我将Maven目标设置为1.7,就像在我的pom.xml中一样:
<configuration>
<source>1.8</source>
<target>1.7</target>
</configuration>
Run Code Online (Sandbox Code Playgroud)
然后代码完美编译,没有错误或任何东西.但是,当我尝试运行代码时,它给了我这个错误:
java.lang.ClassFormatError:类net/uniqraft/murder/match/settings/ISetting中的方法getValueName具有非法修饰符:0x1
我尝试谷歌它但找不到我理解或似乎适用于我的情况.
所以,我想,我只是将整个代码库变成Java 7:
<configuration> …Run Code Online (Sandbox Code Playgroud) 我有一个简单的服务管理器ServiceManager,它有两种方法.Create()创建服务的实例.Provide()返回先前已创建的服务.
我有一个基本的实现,但我想知道是否有一个更清洁的方式.这是我的基本实现ServiceManager:
public class ServiceManager : MonoBehaviour
{
private Dictionary<Type, MonoBehaviour> services = new Dictionary<Type, MonoBehaviour>();
public void Create<T>() where T : MonoBehaviour
{
// Create service
GameObject serviceObject = new GameObject(typeof(T).Name);
serviceObject.transform.SetParent(transform); // make service GO our child
T service = serviceObject.AddComponent<T>(); // attach service to GO
// Register service
services.Add(typeof(T), service);
}
public T Provide<T>() where T : MonoBehaviour
{
return (T)services[typeof(T)]; // notice the cast to T here
} …Run Code Online (Sandbox Code Playgroud) 我有一个关于Java命名约定的快速问题.我读了一些指南,但没有人回答我的具体问题.
我应该使用什么字序?
例如,我有一个抽象类:
abstract class Requirement
Run Code Online (Sandbox Code Playgroud)
如果我想生孩子,我该如何命名?
像这样:
class RequirementOnlyPlayer extends Requirement
class RequirementOnlyConsole extends Requirement
class RequirementArgumentCount extends Requirement
Run Code Online (Sandbox Code Playgroud)
或者像这样:
class OnlyPlayerRequirement extends Requirement
class OnlyConsoleRequirement extends Requirement
class ArgumentCountRequirement extends Requirement
Run Code Online (Sandbox Code Playgroud)
或者以其他方式?我想这是我的第一个例子,但我不确定.
这就是如何使用这些要求:
addRequirement(new RequirementOnlyPlayer());
addRequirement(new RequirementArgumentCount(3));
Run Code Online (Sandbox Code Playgroud)
任何帮助或反馈将不胜感激!对不起,如果这是一个"nooby"问题,我对Java和编程总体上非常有经验,但出于某种原因,我仍然不太确定.
我在我的项目中使用 commons-io 并想要对其进行着色。我遇到了一个我似乎无法弄清楚的警告:
[WARNING] commons-io-2.7.jar, murder-1.0-SNAPSHOT.jar define 180 overlapping classes and resources:
...
Run Code Online (Sandbox Code Playgroud)
我觉得这很奇怪,因为murder-1.0-SNAPSHOT.jar我正在尝试构建的 jar 应该包含 commons-io jar。
我这样定义我的 commons-io 依赖项:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
(我以为我应该使用runtime范围,但后来我无法运行package,因为它抱怨FileUtils找不到)
这是我的阴影插件的配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>commons-io:commons-io</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我完全删除<filters>,我只会收到此警告:
commons-io-2.7.jar, murder-1.0-SNAPSHOT.jar define 1 overlapping resource
[WARNING] - META-INF/MANIFEST.MF …Run Code Online (Sandbox Code Playgroud)