package com.elyong.noway;
/**
* Created by ely ong on 2017/11/27.
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SimpleGui3C implements ActionListener{
JFrame frame;
public static void main(String[] args){
SimpleGui3C gui=new SimpleGui3C();
gui.go();
}
public void go(){
//你的這里沒有賦值
frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button=new JButton("Change colors");
button.addActionListener(this);
MyDrawPanel drawPanel=new MyDrawPanel();
frame.getContentPane().add(BorderLayout.SOUTH,button);
frame.getContentPane().add(BorderLayout.CENTER,drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event){
frame.repaint();
}
}
class MyDrawPanel extends JPanel{
public void paintComponent(Graphics g){
Graphics2D g2d=(Graphics2D) g;
int red=(int)(Math.random()*255);
int green=(int)(Math.random()*255);
int blue=(int)(Math.random()*255);
Color startColor=new Color(red,green,blue);
red=(int)(Math.random()*255);
green=(int)(Math.random()*255);
blue=(int)(Math.random()*255);
Color endColor=new Color(red,green,blue);
GradientPaint gradient=new GradientPaint(70,70,startColor,150,150,endColor);
g2d.setPaint(gradient);
g2d.fillOval(70,70,100,100);
}
}有一定的區(qū)別,如果沒有特殊需求,也沒有用到new String("123") 的需求。
String str1="ABC"; 和String str2 = new String("ABC");
String str1="ABC" 可能創(chuàng)建一個(gè)對(duì)象或者不創(chuàng)建對(duì)象,如果"ABC"這個(gè)字符串在java String池里不存在,會(huì)在java String池創(chuàng)建這個(gè)一個(gè)String對(duì)象("ABC").如果已經(jīng)存在,str1直接reference to 這個(gè)String池里的對(duì)象。
String str2 = new String("ABC") 至少創(chuàng)建一個(gè)對(duì)象,也可能兩個(gè)。因?yàn)橛玫絥ew 關(guān)鍵字,會(huì)在heap創(chuàng)建一個(gè) str2 的String 對(duì)象,它的value 是 "ABC".同時(shí),如果"ABC"這個(gè)字符串在java String池里不存在,會(huì)在java String池創(chuàng)建這個(gè)一個(gè)String對(duì)象("ABC").
@Deprecated
/* */ public static native Class<?> getCallerClass(int paramInt);
加上int型參數(shù),
沒用過這個(gè)方法,嘗試一下
0:返回sun.reflect.Reflection
1:返回當(dāng)前類的Class對(duì)象
2:返回調(diào)用該方法的Class對(duì)象
你說的是 {@link xxx} ?
你這個(gè)是超時(shí)了,先ping一下服務(wù)器,確保能ping通,然后再看看服務(wù)器防火墻是不是沒有開放端口,定位出問題的點(diǎn)
用session
在你用戶沒有訪問權(quán)限,然后重定向之前,這個(gè)時(shí)候你將當(dāng)前路徑存入session
在你登錄之后再取出session里面的路徑,重定向到該路徑即可
使用這個(gè)chrome插件吧,Sourcegraph for GitHub 安裝完成之后就回出現(xiàn)這個(gè)按鈕
點(diǎn)擊就會(huì)調(diào)轉(zhuǎn)到 一個(gè)在線的IDE可以跳轉(zhuǎn)的
new HashMap<>()的時(shí)候 entrySet就已經(jīng)不為null了 不知道是不是底層賦值的?
DelayQueue 了解一下
尷尬,還是溜了
public class test {
public static List> source;
public static void main(String[] args) {
source = new ArrayList<>();
List<String> a = new ArrayList<String>();
a.add("黑色");
a.add("白色");
List<String> b = new ArrayList<String>();
b.add("64G");
b.add("128G");
List<String> c = new ArrayList<String>();
c.add("中國(guó)聯(lián)通");
c.add("中國(guó)移動(dòng)");
source.add(a);
source.add(b);
source.add(c);
ArrayList<String> result = new ArrayList<>();
recursion(result, source.get(0), 0, "");
System.out.println(result);
}
public static void recursion(List<String> result, List<String> para, int num, String choose) {
for (int i = 0; i < para.size(); i++) {
if (source.size() == num + 1) {
result.add(choose + "/" + para.get(i));
} else {
recursion(result, source.get(num + 1), num + 1, choose + "/" + para.get(i));
}
}
}
}
試過在module1-service中添加自定義datasource(只支持properties,Yml可能能實(shí)現(xiàn),但還不太會(huì)寫),可以實(shí)現(xiàn)(此種方式不清楚是否會(huì)影響原來(lái)spring datasource機(jī)制,對(duì)spring原理不熟)
代碼如下:
@Component
@ConfigurationProperties(prefix = "spring.datasource")
@PropertySource("classpath:service-jdbc.properties")
public class MyDataSourceProperties {
private String url;
...
}
@EnableConfigurationProperties(MyDataSourceProperties.class)
public class MyDataSourceConfig {
@Autowired
private MyDataSourceProperties myDataSourceProperties;
@Bean
@Primary
public DataSource dataSource() {
return DataSourceBuilder.create(myDataSourceProperties.getClassLoader()).type(myDataSourceProperties.getType()).driverClassName(myDataSourceProperties.determineDriverClassName()).url(myDataSourceProperties.determineUrl()).username(myDataSourceProperties.determineUsername()).password(myDataSourceProperties.determinePassword()).build();
}
}
完整代碼:https://gitee.com/soft_xiang/...
在module1-service中自定義properties bean(此種方法較好,推薦),代碼如下
@Configuration
public class ServiceConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("application-module1-service.yml"));
configurer.setProperties(yaml.getObject());
return configurer;
}
}
由第二種用法引起的新的問題:
項(xiàng)目中如果存在多環(huán)境配置文件,如application-module1-service-dev.yml/application-module1-service-test.yml/application-module1-service/-release.yml時(shí),怎樣根據(jù)module1-web中配置的spring.profiles.active加載對(duì)應(yīng)的配置文件?
思路為在加載文件時(shí)使用SpringContextUtil獲取配置文件中的active,在properties()中根據(jù)active加載文件
代碼如下:
SpringContextUtil.java
@Order(Integer.MIN_VALUE)
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext context = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.context = applicationContext;
}
/// 獲取當(dāng)前環(huán)境
public static String getActiveProfile() {
return context.getEnvironment().getActiveProfiles()[0];
}
/// 獲取當(dāng)前環(huán)境
public static String[] getActiveProfiles() {
return context.getEnvironment().getActiveProfiles();
}
}
ServiceConfig
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
String path = "application-module1-service.yml";
try {
String profile = SpringContextUtil.getActiveProfile();
if (StringUtils.isNotBlank(profile)) {
path = "application-module1-service-" + profile + ".yml";
}
}catch (NullPointerException e){
e.printStackTrace();
System.out.println("SpringContextUtil...未加載...");
}
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource(path));//File引入
configurer.setProperties(yaml.getObject());
return configurer;
}
完整代碼:https://gitee.com/soft_xiang/...
然而這里會(huì)有循環(huán)依賴問題
運(yùn)行代碼會(huì)有
SpringContextUtil...未加載...
沒有實(shí)現(xiàn)根據(jù)active加載對(duì)應(yīng)配置文件
String都標(biāo)紅了,估計(jì)你沒配置jdk吧
在File->Project Structure->Project配置一下jdk
那用戶信息是如何獲取的呢?
請(qǐng)求后端獲取的。
這個(gè)問題太泛,百度搜一下,有很多有價(jià)值的東西。
var obj = [
{
"省會(huì)": "北京123",
"金額": 29097061.66
},
{
"省會(huì)": "廣州123",
"金額": 19784491.69
},
{
"省會(huì)": "杭州123",
"金額": 14068375.59
},
{
"省會(huì)": "南1京1",
"金額": 13391405.93
},
{
"省會(huì)": "香22港3",
"金額": 11244012.29
},
{
"省會(huì)": "香22港3",
"金額": 11244012.29
},
{
"省會(huì)": "香22港3",
"金額": 11244012.29
}
] //此處是原始數(shù)據(jù)
var obj1 = [
{
"省會(huì)": "北京123",
"金額": 29097061.66
},
{
"省會(huì)": "廣州123",
"金額": 19784491.69
},
{
"省會(huì)": "杭州123",
"金額": 14068375.59
},
{
"省會(huì)": "南1京1",
"金額": 13391405.93
},
{
"省會(huì)": "香22港3",
"金額": 11244012.29
},
{
"省會(huì)": "香22港3",
"金額": 11244012.29
},
{
"省會(huì)": "臺(tái)灣",
"金額": 11244012.29
}
] //此處是取發(fā)生變化后的數(shù)據(jù)
for (var i = 0 ; i < obj.length; i++) {
if (obj[i].金額 == obj1[i].金額 && obj1[i].省會(huì) == obj1[i].省會(huì)) {
} else {
obj[i].金額 = "此處填寫要替換成什么值";
obj[i].省會(huì) = "此處填寫要替換成什么值";
}
}
//最后obj就是替換成功后的新對(duì)象數(shù)組
不是輸入模式下
:set highlight 設(shè)置語(yǔ)法高亮的.試試json能不能高亮
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問,美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。