我最近在"Red Hat Enterprise Linux Server(6.6)"上安装了"apache-tomee-webprofile-1.7.2".
我可以通过访问xxxx:8080来访问Tomcat主页,通过这个,我可以访问"服务器状态","管理器应用程序"和"主机管理器"页面.但是,当我访问"TomEE GUI"页面时,我收到"错误404:描述所请求的资源不可用".页.
从我所看到的Tomee运行时,当我访问"管理应用程序"页面时,"/ tomee"就在那里,它的运行状态为真.
我是TomEE的新手,所以可能有一个我错过/完成错误的步骤.所以任何有关如何使这项工作的帮助都会很棒.
我不确定哪个代码与此问题相关,所以请告诉我哪些配置会有所帮助,我会发布它.
在Hibernate上处理我的第一个应用程序时.在尝试从数据库中检索User对象时,我收到以下异常:
org.hibernate.TypeMismatchException:为类org.cw.form.User提供了错误类型的id.预期:类java.lang.Integer,org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java: 906)org.hibernate.impl.SessionImpl.load(SessionImpl.java:823)atg.hibernate.impl.SessionImpl.load(SessionImpl.java:816)
我用以下postgreSQL创建了USERS表:
CREATE SEQUENCE user2_id_seq;
CREATE TABLE USERS(id integer NOT NULL DEFAULT nextval('user2_id_seq'), user_name varchar(45) NOT NULL UNIQUE , password varchar(45) NOT NULL, email varchar(45) NOT NULL, PRIMARY KEY (id));
Run Code Online (Sandbox Code Playgroud)
用户实体定义如下:
@Entity @Table(name="USERS") public class User {
@Id
@Column(name="ID")
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
@Column(name="USER_NAME", unique = true)
private String userName;
@Column(name="PASSWORD")
private String password;
@Column(name="EMAIL")
private String email; .. all the getters and setters...
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我正在尝试调试一个使用 Lambda 表达式的简单 Java 应用程序。我无法使用普通 Eclipse 调试器调试 Lambda 表达式。
我有一个帖子:
class Foo extends Thread
{
boolean active = true;
public void run()
{
while(active)
{
//do stuff
}
}
public void end()
{
active = false;
}
public void hibernate()
{
synchronized(this)
{
wait();
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果另一个线程调用end()
,会Foo
立即看到active
现在是false
什么?具体来说,因为active
不是volatile
,我不确定它会不会.我最初创建的end()
是一种避免易变的聪明方法,但现在我不确定它实际上会做我想做的事情.另外,如果另一个线程调用hibernate()
,哪个线程将进入休眠状态?我打算Foo
睡觉,所以如果这不符合我的意图,那么另一个建议将非常受欢迎.
在我的 Mac-pro OS-X Yosemite 上,我使用 Jenv 安装 java7 和 java8。
$ brew cask install java8
$ brew cask install java7
Run Code Online (Sandbox Code Playgroud)
然后对每个 java 执行“jenv add”命令,如下所示:
$ sudo jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/
Run Code Online (Sandbox Code Playgroud)
添加了oracle64-1.7.0.80
我可以在 /Users/xxxxx/.jenv/versions 中看到两者
$ ls -lrt
Run Code Online (Sandbox Code Playgroud)
lrwxr-xr-x 1根员工2月1日64日13:42 oracle64-1.8.0.121 -> /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
lrwxr-xr-x 1根员工2月1日63日13:49 oracle64-1.7.0.80 -> /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
但是当我尝试将java8设置为全局时,它说未安装java8。
$ jenv global oracle64-1.8.0.121
Run Code Online (Sandbox Code Playgroud)
jenv:未安装版本“oracle64-1.8.0.121”
我在这里错过了什么吗?我该如何解决这个问题?
我想在 Spring Boot 中使用 RedisTemplate。我可以成功使用StringRedisTemplate,但无法使用RedisTemplate。这是代码。
\n\n@RunWith(SpringRunner.class)\n@SpringBootTest\npublic class RedisEntityTests {\n\n @Autowired\n private StringRedisTemplate stringRedisTemplate;\n\n @Autowired\n private RedisTemplate<String, RedisEntity> redisTemplate;\n\n // This test case can run successfully.\n @Test\n public void testString() {\n // save string\n stringRedisTemplate.opsForValue().set("aaa", "111");\n Assert.assertEquals("111", stringRedisTemplate.opsForValue().get("aaa"));\n }\n\n // This test case I got error.\n @Test\n public void testObject() throws Exception {\n // save object\n RedisEntity redisEntity = new RedisEntity("Tom", 20);\n redisTemplate.opsForValue().set(redisEntity.getName(), redisEntity);\n\n Assert.assertEquals(20, (redisTemplate.opsForValue().get("Tom")).getAge().longValue());\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n然后,运行测试方法\xef\xbc\x9atestObject(),这里是错误报告\xef\xbc\x9a
\n\n\n2017-12-17 16:12:12.079 错误 4708 --- [ main]\n ostest.context.TestContextManager :在允许 …
最近我切换到Spring Boot 2
了Micrometer
. 当我获得这些闪亮的新指标时,我与我们的 DevOps 人员进行了交谈,我们开始将它们导出到Telegraf
.
为了区分不同的应用程序和应用程序节点,我们决定使用标签。这对于自定义指标非常有效,但现在我开始考虑预定义。为了对默认指标实现相同的目标,我还需要能够为它们添加额外的标签。
有可能实现这一目标吗?我这样做对吗?
编辑:我尝试了下一种方法:
@Component
public class MyMetricsImpl implements MyMetrics {
@Autowired
protected MyProperties myProperties;
@Autowired
protected MeterRegistry meterRegistry;
@PostConstruct
public void initialize() {
this.meterRegistry.config()
.commonTags(commonTags());
}
@Override
public List<Tag> commonTags() {
List<Tag> tags = new ArrayList<>();
tags.add(Tag.of("application", myProperties.getApplicationName()));
tags.add(Tag.of("node", myProperties.getNodeName()));
return tags;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是我的指标表现正确,甚至一些引导指标(至少http.server.requests
)看到我的标签。但是jvm.*
,system.*
,tomcat.*
和其他许多人仍然不具备所需的标签。
我想知道是否有人可以帮助使用 ScatterZipOutputStream 实现并行 Zip 创建。我已经搜索了很多,但没有找到相同的示例。
https://commons.apache.org/proper/commons-compress/zip.html
我尝试使用 ZipArchiveOutputStream 制作 Zip、压缩目录等。现在,我正在尝试同时做到这一点。
public static void makeZip(String filename) throws IOException,
ArchiveException {
File sourceFile = new File(filename);
final OutputStream out = new FileOutputStream(filename.substring(0, filename.lastIndexOf('.')) + ".zip");
ZipArchiveOutputStream os = new ZipArchiveOutputStream(out);
os.setUseZip64(Zip64Mode.AsNeeded);
os.putArchiveEntry(new ZipArchiveEntry(sourceFile.getName()));
IOUtils.copy(new FileInputStream(sourceFile), os);
os.closeArchiveEntry();
os.close();
}
Run Code Online (Sandbox Code Playgroud)
它应该能够作为线程处理单个文件,然后将其组合起来写入结果 zip。
版本1
interface HelloWorld{
String hello(String s);
}
HelloWorld h = String::new;
h.hello("Something");
Run Code Online (Sandbox Code Playgroud)
版本2
interface HelloWorld{
void hello(String s);
}
HelloWorld h = String::new;
h.hello("Something");
Run Code Online (Sandbox Code Playgroud)
版本3
interface HelloWorld{
String hello();
}
HelloWorld h = String::new;
h.hello();
Run Code Online (Sandbox Code Playgroud)
版本4
interface HelloWorld{
void hello();
}
HelloWorld h = String::new;
h.hello();
Run Code Online (Sandbox Code Playgroud)
我已经创建了相同代码的四个版本,但我没有更改HelloWorld h = String::new;
我能够理解的第一个案例,它创建了新的String of String,其值在参数中传递并返回对象.
有些人可以详细说明为什么编译器在其他情况下没有给出任何错误并有一些解释?
对于以下两个类,它们具有相同的Java字节码。
Java版本:
Java版本“ 1.8.0_181” Java™SE运行时环境(内部版本1.8.0_181-b13)Java HotSpot(TM)64位服务器VM(内部版本25.181-b13,混合模式)
javac和javap版本:
1.8.0_181
我的疑问是
不应法同步关键字有不同的字节码,我们可以看到在synchronized块中有monitorenter
和monitorexit
,或让我们假设我不应该混合synchronized块和synchronized方法再
JVM如何以不同方式处理这两种方法?
public class MySingleton1 {
private MySingleton1() {}
private static MySingleton1 ourInstance;
public static MySingleton1 getInstance() {
if (ourInstance == null) {
ourInstance = new MySingleton1();
}
return ourInstance;
}
}
Run Code Online (Sandbox Code Playgroud)
和
public class MySingleton2 {
private MySingleton2() {}
private static MySingleton2 ourInstance;
public static synchronized MySingleton2 getInstance() {
if (ourInstance == null) {
ourInstance = new MySingleton2(); …
Run Code Online (Sandbox Code Playgroud)我有一个具有以下示例结构的 json 文件
{
"contract": {
"marketScope": "AT",
"businessPartner": "GBM",
"salesChannelInformation": {
"salesChannelCode": "Integrated",
"salesChannel": "B-Partner information 1"
}
}
Run Code Online (Sandbox Code Playgroud)
给定一个jsonpath,我想修改一个特定的键值。
例如,将“contract.salesChannelInformation.salesChannelCode”更改为值“Integrated-Test”
目前我有以下代码:
public void setProperty(String fileString,String path, String value) {
if(JsonPath.given(fileString).get(path) == null){
Assert.fail("Path does not exist on json file");
}else {
try {
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(fileString);
System.out.println(jsonObject);
String[] tokens = path.split("\\.");
for (String token : tokens) {
System.out.println(token);
// Iterate the JsonObject, reach the key and modify the value
}
} …
Run Code Online (Sandbox Code Playgroud) 可以说我 在课堂上有方法synchronized hi(){}
和synchronized hello(){}
方法ABC
.和两个线程t1
和t2
正在执行t1.hi()
和t2.hello()
分别.它们可以同时执行还是存在任何问题?
我想知道如何在java中创建自己的树,它由8个子节点组成,在每个子节点中它有许多子节点.如何创建这个.请帮我.我比java更新.
java ×10
java-8 ×2
spring-boot ×2
synchronized ×2
apache-tomee ×1
bytecode ×1
debugging ×1
eclipse ×1
hibernate ×1
installation ×1
jakarta-ee ×1
jenv ×1
json ×1
lambda ×1
macos ×1
metrics ×1
micrometer ×1
postgresql ×1
redis ×1
spring ×1
spring-data ×1
tomcat ×1
tomcat7 ×1
tree ×1
volatile ×1
web ×1
zip ×1